2024-01-23 10:54:18 +07:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
from decouple import config
|
|
|
|
from platformdirs import user_cache_dir
|
|
|
|
from theflow.settings.default import * # noqa
|
|
|
|
|
|
|
|
user_cache_dir = Path(
|
|
|
|
user_cache_dir(str(config("KH_APP_NAME", default="ktem")), "Cinnamon")
|
|
|
|
)
|
|
|
|
user_cache_dir.mkdir(parents=True, exist_ok=True)
|
|
|
|
|
|
|
|
|
|
|
|
COHERE_API_KEY = config("COHERE_API_KEY", default="")
|
2024-01-25 19:07:53 +07:00
|
|
|
KH_MODE = "dev"
|
2024-03-15 16:17:33 +07:00
|
|
|
KH_FEATURE_USER_MANAGEMENT = False
|
2024-03-07 14:19:37 +07:00
|
|
|
KH_FEATURE_USER_MANAGEMENT_ADMIN = str(
|
|
|
|
config("KH_FEATURE_USER_MANAGEMENT_ADMIN", default="admin")
|
|
|
|
)
|
|
|
|
KH_FEATURE_USER_MANAGEMENT_PASSWORD = str(
|
|
|
|
config("KH_FEATURE_USER_MANAGEMENT_PASSWORD", default="XsdMbe8zKP8KdeE@")
|
|
|
|
)
|
2024-01-28 19:54:15 +07:00
|
|
|
KH_ENABLE_ALEMBIC = False
|
2024-01-23 10:54:18 +07:00
|
|
|
KH_DATABASE = f"sqlite:///{user_cache_dir / 'sql.db'}"
|
2024-03-15 16:17:33 +07:00
|
|
|
KH_FILESTORAGE_PATH = str(user_cache_dir / "files")
|
|
|
|
|
2024-01-23 10:54:18 +07:00
|
|
|
KH_DOCSTORE = {
|
|
|
|
"__type__": "kotaemon.storages.SimpleFileDocumentStore",
|
|
|
|
"path": str(user_cache_dir / "docstore"),
|
|
|
|
}
|
|
|
|
KH_VECTORSTORE = {
|
|
|
|
"__type__": "kotaemon.storages.ChromaVectorStore",
|
|
|
|
"path": str(user_cache_dir / "vectorstore"),
|
|
|
|
}
|
2024-03-27 19:04:48 +07:00
|
|
|
KH_LLMS = {}
|
|
|
|
KH_EMBEDDINGS = {}
|
|
|
|
|
|
|
|
# populate options from config
|
|
|
|
if config("AZURE_OPENAI_API_KEY", default="") and config(
|
|
|
|
"AZURE_OPENAI_ENDPOINT", default=""
|
|
|
|
):
|
|
|
|
if config("AZURE_OPENAI_CHAT_DEPLOYMENT", default=""):
|
|
|
|
KH_LLMS["azure"] = {
|
2024-04-06 11:53:17 +07:00
|
|
|
"spec": {
|
2024-03-27 19:04:48 +07:00
|
|
|
"__type__": "kotaemon.llms.AzureChatOpenAI",
|
|
|
|
"temperature": 0,
|
|
|
|
"azure_endpoint": config("AZURE_OPENAI_ENDPOINT", default=""),
|
2024-04-06 11:53:17 +07:00
|
|
|
"api_key": config("AZURE_OPENAI_API_KEY", default=""),
|
2024-03-27 19:04:48 +07:00
|
|
|
"api_version": config("OPENAI_API_VERSION", default="")
|
|
|
|
or "2024-02-15-preview",
|
2024-04-06 11:53:17 +07:00
|
|
|
"azure_deployment": config("AZURE_OPENAI_CHAT_DEPLOYMENT", default=""),
|
|
|
|
"timeout": 20,
|
2024-03-27 19:04:48 +07:00
|
|
|
},
|
|
|
|
"default": False,
|
|
|
|
"accuracy": 5,
|
|
|
|
"cost": 5,
|
|
|
|
}
|
|
|
|
if config("AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT", default=""):
|
|
|
|
KH_EMBEDDINGS["azure"] = {
|
2024-04-06 11:53:17 +07:00
|
|
|
"spec": {
|
2024-03-27 19:04:48 +07:00
|
|
|
"__type__": "kotaemon.embeddings.AzureOpenAIEmbeddings",
|
|
|
|
"azure_endpoint": config("AZURE_OPENAI_ENDPOINT", default=""),
|
|
|
|
"openai_api_key": config("AZURE_OPENAI_API_KEY", default=""),
|
|
|
|
"api_version": config("OPENAI_API_VERSION", default="")
|
|
|
|
or "2024-02-15-preview",
|
|
|
|
"deployment": config("AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT", default=""),
|
|
|
|
"request_timeout": 10,
|
|
|
|
"chunk_size": 16,
|
|
|
|
},
|
|
|
|
"default": False,
|
|
|
|
"accuracy": 5,
|
|
|
|
"cost": 5,
|
|
|
|
}
|
|
|
|
|
|
|
|
if config("OPENAI_API_KEY", default=""):
|
|
|
|
KH_LLMS["openai"] = {
|
2024-01-23 10:54:18 +07:00
|
|
|
"def": {
|
2024-03-27 19:04:48 +07:00
|
|
|
"__type__": "kotaemon.llms.ChatOpenAI",
|
|
|
|
"temperature": 0,
|
|
|
|
"openai_api_base": config("OPENAI_API_BASE", default="")
|
|
|
|
or "https://api.openai.com/v1",
|
|
|
|
"openai_api_key": config("OPENAI_API_KEY", default=""),
|
|
|
|
"model": config("OPENAI_CHAT_MODEL", default="") or "gpt-3.5-turbo",
|
|
|
|
"request_timeout": 10,
|
|
|
|
"stream": False,
|
2024-01-23 10:54:18 +07:00
|
|
|
},
|
|
|
|
"default": False,
|
2024-03-27 19:04:48 +07:00
|
|
|
}
|
|
|
|
if len(KH_EMBEDDINGS) < 1:
|
|
|
|
KH_EMBEDDINGS["openai"] = {
|
|
|
|
"def": {
|
|
|
|
"__type__": "kotaemon.embeddings.OpenAIEmbeddings",
|
|
|
|
"openai_api_base": config("OPENAI_API_BASE", default="")
|
|
|
|
or "https://api.openai.com/v1",
|
|
|
|
"openai_api_key": config("OPENAI_API_KEY", default=""),
|
|
|
|
"model": config(
|
|
|
|
"OPENAI_EMBEDDINGS_MODEL", default="text-embedding-ada-002"
|
|
|
|
)
|
|
|
|
or "text-embedding-ada-002",
|
|
|
|
"request_timeout": 10,
|
|
|
|
"chunk_size": 16,
|
|
|
|
},
|
|
|
|
"default": False,
|
|
|
|
}
|
|
|
|
|
|
|
|
if config("LOCAL_MODEL", default=""):
|
|
|
|
KH_LLMS["local"] = {
|
2024-01-23 10:54:18 +07:00
|
|
|
"def": {
|
2024-03-27 19:04:48 +07:00
|
|
|
"__type__": "kotaemon.llms.EndpointChatLLM",
|
|
|
|
"endpoint_url": "http://localhost:31415/v1/chat/completions",
|
2024-01-23 10:54:18 +07:00
|
|
|
},
|
2024-03-15 16:17:33 +07:00
|
|
|
"default": False,
|
2024-03-27 19:04:48 +07:00
|
|
|
"cost": 0,
|
|
|
|
}
|
|
|
|
if len(KH_EMBEDDINGS) < 1:
|
|
|
|
KH_EMBEDDINGS["local"] = {
|
|
|
|
"def": {
|
|
|
|
"__type__": "kotaemon.embeddings.EndpointEmbeddings",
|
|
|
|
"endpoint_url": "http://localhost:31415/v1/embeddings",
|
|
|
|
},
|
|
|
|
"default": False,
|
|
|
|
"cost": 0,
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-01-26 22:31:52 +07:00
|
|
|
KH_REASONINGS = ["ktem.reasoning.simple.FullQAPipeline"]
|
2024-04-03 14:52:40 +07:00
|
|
|
KH_VLM_ENDPOINT = "{0}/openai/deployments/{1}/chat/completions?api-version={2}".format(
|
|
|
|
config("AZURE_OPENAI_ENDPOINT", default=""),
|
|
|
|
config("OPENAI_VISION_DEPLOYMENT_NAME", default="gpt-4-vision"),
|
|
|
|
config("OPENAI_API_VERSION", default=""),
|
|
|
|
)
|
2024-01-23 10:54:18 +07:00
|
|
|
|
|
|
|
|
|
|
|
SETTINGS_APP = {
|
|
|
|
"lang": {
|
|
|
|
"name": "Language",
|
|
|
|
"value": "en",
|
|
|
|
"choices": [("English", "en"), ("Japanese", "ja")],
|
|
|
|
"component": "dropdown",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SETTINGS_REASONING = {
|
|
|
|
"use": {
|
|
|
|
"name": "Reasoning options",
|
|
|
|
"value": None,
|
|
|
|
"choices": [],
|
|
|
|
"component": "radio",
|
|
|
|
},
|
|
|
|
"lang": {
|
|
|
|
"name": "Language",
|
|
|
|
"value": "en",
|
|
|
|
"choices": [("English", "en"), ("Japanese", "ja")],
|
|
|
|
"component": "dropdown",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-03-07 01:50:47 +07:00
|
|
|
KH_INDEX_TYPES = ["ktem.index.file.FileIndex"]
|
|
|
|
KH_INDICES = [
|
|
|
|
{
|
|
|
|
"id": 1,
|
|
|
|
"name": "File",
|
|
|
|
"config": {},
|
|
|
|
"index_type": "ktem.index.file.FileIndex",
|
2024-04-06 11:53:17 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"id": 2,
|
|
|
|
"name": "Sample",
|
|
|
|
"config": {},
|
|
|
|
"index_type": "ktem.index.file.FileIndex",
|
|
|
|
},
|
2024-03-07 01:50:47 +07:00
|
|
|
]
|