DocsGPT/application/core/settings.py

45 lines
2.0 KiB
Python
Raw Normal View History

2023-04-29 14:40:55 +00:00
from pathlib import Path
2023-12-22 14:03:43 +00:00
from typing import Optional
2023-10-01 16:20:47 +00:00
import os
2023-04-29 14:40:55 +00:00
2023-12-22 14:03:43 +00:00
from pydantic_settings import BaseSettings
2023-10-01 18:16:13 +00:00
current_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
2023-04-29 14:40:55 +00:00
class Settings(BaseSettings):
2024-01-08 23:35:37 +00:00
LLM_NAME: str = "docsgpt"
EMBEDDINGS_NAME: str = "huggingface_sentence-transformers/all-mpnet-base-v2"
2023-04-30 10:03:09 +00:00
CELERY_BROKER_URL: str = "redis://localhost:6379/0"
CELERY_RESULT_BACKEND: str = "redis://localhost:6379/1"
MONGO_URI: str = "mongodb://localhost:27017/docsgpt"
2023-10-01 16:20:47 +00:00
MODEL_PATH: str = os.path.join(current_dir, "models/docsgpt-7b-f16.gguf")
TOKENS_MAX_HISTORY: int = 150
2023-09-27 15:25:57 +00:00
UPLOAD_FOLDER: str = "inputs"
2023-10-01 10:28:06 +00:00
VECTOR_STORE: str = "faiss" # "faiss" or "elasticsearch"
API_URL: str = "http://localhost:7091" # backend url for celery worker
2023-04-29 14:56:32 +00:00
2023-12-22 14:03:43 +00:00
API_KEY: Optional[str] = None # LLM api key
EMBEDDINGS_KEY: Optional[str] = None # api key for embeddings (if using openai, just copy API_KEY)
OPENAI_API_BASE: Optional[str] = None # azure openai api base url
OPENAI_API_VERSION: Optional[str] = None # azure openai api version
AZURE_DEPLOYMENT_NAME: Optional[str] = None # azure deployment name for answering
AZURE_EMBEDDINGS_DEPLOYMENT_NAME: Optional[str] = None # azure deployment name for embeddings
2023-04-29 14:40:55 +00:00
2023-09-29 16:17:48 +00:00
# elasticsearch
2023-12-22 14:03:43 +00:00
ELASTIC_CLOUD_ID: Optional[str] = None # cloud id for elasticsearch
ELASTIC_USERNAME: Optional[str] = None # username for elasticsearch
ELASTIC_PASSWORD: Optional[str] = None # password for elasticsearch
ELASTIC_URL: Optional[str] = None # url for elasticsearch
ELASTIC_INDEX: Optional[str] = "docsgpt" # index name for elasticsearch
2023-09-29 16:17:48 +00:00
2023-10-06 00:52:29 +00:00
# SageMaker config
2023-12-22 14:03:43 +00:00
SAGEMAKER_ENDPOINT: Optional[str] = None # SageMaker endpoint name
SAGEMAKER_REGION: Optional[str] = None # SageMaker region name
SAGEMAKER_ACCESS_KEY: Optional[str] = None # SageMaker access key
SAGEMAKER_SECRET_KEY: Optional[str] = None # SageMaker secret key
2023-10-06 00:52:29 +00:00
2023-04-29 14:40:55 +00:00
path = Path(__file__).parent.parent.absolute()
settings = Settings(_env_file=path.joinpath(".env"), _env_file_encoding="utf-8")