Spaces:
Build error
Build error
ian
commited on
Commit
·
476a48c
1
Parent(s):
0761598
update
Browse files- flowsettings.py +172 -0
- requirements.txt +1 -1
flowsettings.py
ADDED
@@ -0,0 +1,172 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from pathlib import Path
|
2 |
+
|
3 |
+
from decouple import config
|
4 |
+
from platformdirs import user_cache_dir
|
5 |
+
from theflow.settings.default import * # noqa
|
6 |
+
|
7 |
+
user_cache_dir = Path(
|
8 |
+
user_cache_dir(str(config("KH_APP_NAME", default="ktem")), "Cinnamon")
|
9 |
+
)
|
10 |
+
user_cache_dir.mkdir(parents=True, exist_ok=True)
|
11 |
+
|
12 |
+
|
13 |
+
COHERE_API_KEY = config("COHERE_API_KEY", default="")
|
14 |
+
KH_MODE = "dev"
|
15 |
+
KH_FEATURE_USER_MANAGEMENT = False
|
16 |
+
KH_FEATURE_USER_MANAGEMENT_ADMIN = str(
|
17 |
+
config("KH_FEATURE_USER_MANAGEMENT_ADMIN", default="admin")
|
18 |
+
)
|
19 |
+
KH_FEATURE_USER_MANAGEMENT_PASSWORD = str(
|
20 |
+
config("KH_FEATURE_USER_MANAGEMENT_PASSWORD", default="Abc@123")
|
21 |
+
)
|
22 |
+
KH_ENABLE_ALEMBIC = False
|
23 |
+
KH_DATABASE = f"sqlite:///{user_cache_dir / 'sql.db'}"
|
24 |
+
KH_FILESTORAGE_PATH = str(user_cache_dir / "files")
|
25 |
+
|
26 |
+
KH_DOCSTORE = {
|
27 |
+
"__type__": "kotaemon.storages.SimpleFileDocumentStore",
|
28 |
+
"path": str(user_cache_dir / "docstore"),
|
29 |
+
}
|
30 |
+
KH_VECTORSTORE = {
|
31 |
+
"__type__": "kotaemon.storages.ChromaVectorStore",
|
32 |
+
"path": str(user_cache_dir / "vectorstore"),
|
33 |
+
}
|
34 |
+
KH_LLMS = {}
|
35 |
+
KH_EMBEDDINGS = {}
|
36 |
+
|
37 |
+
# populate options from config
|
38 |
+
if config("AZURE_OPENAI_API_KEY", default="") and config(
|
39 |
+
"AZURE_OPENAI_ENDPOINT", default=""
|
40 |
+
):
|
41 |
+
if config("AZURE_OPENAI_CHAT_DEPLOYMENT", default=""):
|
42 |
+
KH_LLMS["azure"] = {
|
43 |
+
"spec": {
|
44 |
+
"__type__": "kotaemon.llms.AzureChatOpenAI",
|
45 |
+
"temperature": 0,
|
46 |
+
"azure_endpoint": config("AZURE_OPENAI_ENDPOINT", default=""),
|
47 |
+
"api_key": config("AZURE_OPENAI_API_KEY", default=""),
|
48 |
+
"api_version": config("OPENAI_API_VERSION", default="")
|
49 |
+
or "2024-02-15-preview",
|
50 |
+
"azure_deployment": config("AZURE_OPENAI_CHAT_DEPLOYMENT", default=""),
|
51 |
+
"timeout": 20,
|
52 |
+
},
|
53 |
+
"default": False,
|
54 |
+
"accuracy": 5,
|
55 |
+
"cost": 5,
|
56 |
+
}
|
57 |
+
if config("AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT", default=""):
|
58 |
+
KH_EMBEDDINGS["azure"] = {
|
59 |
+
"spec": {
|
60 |
+
"__type__": "kotaemon.embeddings.AzureOpenAIEmbeddings",
|
61 |
+
"azure_endpoint": config("AZURE_OPENAI_ENDPOINT", default=""),
|
62 |
+
"api_key": config("AZURE_OPENAI_API_KEY", default=""),
|
63 |
+
"api_version": config("OPENAI_API_VERSION", default="")
|
64 |
+
or "2024-02-15-preview",
|
65 |
+
"azure_deployment": config(
|
66 |
+
"AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT", default=""
|
67 |
+
),
|
68 |
+
"timeout": 10,
|
69 |
+
},
|
70 |
+
"default": False,
|
71 |
+
}
|
72 |
+
|
73 |
+
if config("OPENAI_API_KEY", default=""):
|
74 |
+
KH_LLMS["openai"] = {
|
75 |
+
"spec": {
|
76 |
+
"__type__": "kotaemon.llms.ChatOpenAI",
|
77 |
+
"temperature": 0,
|
78 |
+
"base_url": config("OPENAI_API_BASE", default="")
|
79 |
+
or "https://api.openai.com/v1",
|
80 |
+
"api_key": config("OPENAI_API_KEY", default=""),
|
81 |
+
"model": config("OPENAI_CHAT_MODEL", default="") or "gpt-3.5-turbo",
|
82 |
+
"timeout": 10,
|
83 |
+
},
|
84 |
+
"default": False,
|
85 |
+
}
|
86 |
+
if len(KH_EMBEDDINGS) < 1:
|
87 |
+
KH_EMBEDDINGS["openai"] = {
|
88 |
+
"spec": {
|
89 |
+
"__type__": "kotaemon.embeddings.OpenAIEmbeddings",
|
90 |
+
"base_url": config("OPENAI_API_BASE", default="")
|
91 |
+
or "https://api.openai.com/v1",
|
92 |
+
"api_key": config("OPENAI_API_KEY", default=""),
|
93 |
+
"model": config(
|
94 |
+
"OPENAI_EMBEDDINGS_MODEL", default="text-embedding-ada-002"
|
95 |
+
)
|
96 |
+
or "text-embedding-ada-002",
|
97 |
+
"timeout": 10,
|
98 |
+
},
|
99 |
+
"default": False,
|
100 |
+
}
|
101 |
+
|
102 |
+
if config("LOCAL_MODEL", default=""):
|
103 |
+
KH_LLMS["local"] = {
|
104 |
+
"spec": {
|
105 |
+
"__type__": "kotaemon.llms.EndpointChatLLM",
|
106 |
+
"endpoint_url": "http://localhost:31415/v1/chat/completions",
|
107 |
+
},
|
108 |
+
"default": False,
|
109 |
+
"cost": 0,
|
110 |
+
}
|
111 |
+
if len(KH_EMBEDDINGS) < 1:
|
112 |
+
KH_EMBEDDINGS["local"] = {
|
113 |
+
"spec": {
|
114 |
+
"__type__": "kotaemon.embeddings.EndpointEmbeddings",
|
115 |
+
"endpoint_url": "http://localhost:31415/v1/embeddings",
|
116 |
+
},
|
117 |
+
"default": False,
|
118 |
+
"cost": 0,
|
119 |
+
}
|
120 |
+
|
121 |
+
if len(KH_EMBEDDINGS) < 1:
|
122 |
+
KH_EMBEDDINGS["local-mxbai-large-v1"] = {
|
123 |
+
"spec": {
|
124 |
+
"__type__": "kotaemon.embeddings.FastEmbedEmbeddings",
|
125 |
+
"model_name": "mixedbread-ai/mxbai-embed-large-v1",
|
126 |
+
},
|
127 |
+
"default": True,
|
128 |
+
}
|
129 |
+
|
130 |
+
KH_REASONINGS = ["ktem.reasoning.simple.FullQAPipeline"]
|
131 |
+
KH_VLM_ENDPOINT = "{0}/openai/deployments/{1}/chat/completions?api-version={2}".format(
|
132 |
+
config("AZURE_OPENAI_ENDPOINT", default=""),
|
133 |
+
config("OPENAI_VISION_DEPLOYMENT_NAME", default="gpt-4-vision"),
|
134 |
+
config("OPENAI_API_VERSION", default=""),
|
135 |
+
)
|
136 |
+
|
137 |
+
|
138 |
+
SETTINGS_APP = {
|
139 |
+
"lang": {
|
140 |
+
"name": "Language",
|
141 |
+
"value": "en",
|
142 |
+
"choices": [("English", "en"), ("Japanese", "ja")],
|
143 |
+
"component": "dropdown",
|
144 |
+
}
|
145 |
+
}
|
146 |
+
|
147 |
+
|
148 |
+
SETTINGS_REASONING = {
|
149 |
+
"use": {
|
150 |
+
"name": "Reasoning options",
|
151 |
+
"value": None,
|
152 |
+
"choices": [],
|
153 |
+
"component": "radio",
|
154 |
+
},
|
155 |
+
"lang": {
|
156 |
+
"name": "Language",
|
157 |
+
"value": "en",
|
158 |
+
"choices": [("English", "en"), ("Japanese", "ja")],
|
159 |
+
"component": "dropdown",
|
160 |
+
},
|
161 |
+
}
|
162 |
+
|
163 |
+
|
164 |
+
KH_INDEX_TYPES = ["ktem.index.file.FileIndex"]
|
165 |
+
KH_INDICES = [
|
166 |
+
{
|
167 |
+
"id": 1,
|
168 |
+
"name": "File",
|
169 |
+
"config": {},
|
170 |
+
"index_type": "ktem.index.file.FileIndex",
|
171 |
+
},
|
172 |
+
]
|
requirements.txt
CHANGED
@@ -1 +1 @@
|
|
1 |
-
kotaemon-app @ git+https://github.com/Cinnamon/kotaemon.git@
|
|
|
1 |
+
kotaemon-app @ git+https://github.com/Cinnamon/kotaemon.git@d1e3dd178afda7b6d377a000593301e646b8c01f
|