feat: introduce pydantic-settings for config definition and validation (#5202)
Co-authored-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
43
api/configs/middleware/__init__.py
Normal file
43
api/configs/middleware/__init__.py
Normal file
@@ -0,0 +1,43 @@
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from configs.middleware.redis_configs import RedisConfigs
|
||||
|
||||
|
||||
class StorageConfigs(BaseModel):
|
||||
STORAGE_TYPE: str = Field(
|
||||
description='storage type,'
|
||||
' default to `local`,'
|
||||
' available values are `local`, `s3`, `azure-blob`, `aliyun-oss`, `google-storage`.',
|
||||
default='local',
|
||||
)
|
||||
|
||||
STORAGE_LOCAL_PATH: str = Field(
|
||||
description='local storage path',
|
||||
default='storage',
|
||||
)
|
||||
|
||||
|
||||
class VectorStoreConfigs(BaseModel):
|
||||
VECTOR_STORE: Optional[str] = Field(
|
||||
description='vector store type',
|
||||
default=None,
|
||||
)
|
||||
|
||||
|
||||
class KeywordStoreConfigs(BaseModel):
|
||||
KEYWORD_STORE: str = Field(
|
||||
description='keyword store type',
|
||||
default='jieba',
|
||||
)
|
||||
|
||||
|
||||
class MiddlewareConfigs(
|
||||
# place the configs in alphabet order
|
||||
KeywordStoreConfigs,
|
||||
RedisConfigs,
|
||||
StorageConfigs,
|
||||
VectorStoreConfigs,
|
||||
):
|
||||
pass
|
||||
Reference in New Issue
Block a user