Spaces:
Runtime error
Runtime error
Tadashi
commited on
fix: update Dockerfile
Browse files- Dockerfile +1 -1
- flowsettings.py +0 -312
Dockerfile
CHANGED
@@ -7,9 +7,9 @@ RUN --mount=type=ssh chown -R user:user /usr/local/lib/python3.10
|
|
7 |
USER user
|
8 |
WORKDIR /app
|
9 |
|
10 |
-
COPY flowsettings.py /app
|
11 |
COPY app.py /app
|
12 |
|
13 |
ENV GRADIO_SERVER_NAME=0.0.0.0
|
|
|
14 |
ENTRYPOINT ["python", "app.py"]
|
15 |
EXPOSE 7860
|
|
|
7 |
USER user
|
8 |
WORKDIR /app
|
9 |
|
|
|
10 |
COPY app.py /app
|
11 |
|
12 |
ENV GRADIO_SERVER_NAME=0.0.0.0
|
13 |
+
ENV KH_FEATURE_USER_MANAGEMENT=false
|
14 |
ENTRYPOINT ["python", "app.py"]
|
15 |
EXPOSE 7860
|
flowsettings.py
DELETED
@@ -1,312 +0,0 @@
|
|
1 |
-
import os
|
2 |
-
from importlib.metadata import version
|
3 |
-
from inspect import currentframe, getframeinfo
|
4 |
-
from pathlib import Path
|
5 |
-
|
6 |
-
from decouple import config
|
7 |
-
from theflow.settings.default import * # noqa
|
8 |
-
|
9 |
-
cur_frame = currentframe()
|
10 |
-
if cur_frame is None:
|
11 |
-
raise ValueError("Cannot get the current frame.")
|
12 |
-
this_file = getframeinfo(cur_frame).filename
|
13 |
-
this_dir = Path(this_file).parent
|
14 |
-
|
15 |
-
# change this if your app use a different name
|
16 |
-
KH_PACKAGE_NAME = "kotaemon_app"
|
17 |
-
|
18 |
-
KH_APP_VERSION = config("KH_APP_VERSION", None)
|
19 |
-
if not KH_APP_VERSION:
|
20 |
-
try:
|
21 |
-
# Caution: This might produce the wrong version
|
22 |
-
# https://stackoverflow.com/a/59533071
|
23 |
-
KH_APP_VERSION = version(KH_PACKAGE_NAME)
|
24 |
-
except Exception:
|
25 |
-
KH_APP_VERSION = "local"
|
26 |
-
|
27 |
-
KH_ENABLE_FIRST_SETUP = True
|
28 |
-
KH_DEMO_MODE = config("KH_DEMO_MODE", default=False, cast=bool)
|
29 |
-
|
30 |
-
# App can be ran from anywhere and it's not trivial to decide where to store app data.
|
31 |
-
# So let's use the same directory as the flowsetting.py file.
|
32 |
-
KH_APP_DATA_DIR = this_dir / "ktem_app_data"
|
33 |
-
KH_APP_DATA_EXISTS = KH_APP_DATA_DIR.exists()
|
34 |
-
KH_APP_DATA_DIR.mkdir(parents=True, exist_ok=True)
|
35 |
-
|
36 |
-
# User data directory
|
37 |
-
KH_USER_DATA_DIR = KH_APP_DATA_DIR / "user_data"
|
38 |
-
KH_USER_DATA_DIR.mkdir(parents=True, exist_ok=True)
|
39 |
-
|
40 |
-
# markdown output directory
|
41 |
-
KH_MARKDOWN_OUTPUT_DIR = KH_APP_DATA_DIR / "markdown_cache_dir"
|
42 |
-
KH_MARKDOWN_OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
|
43 |
-
|
44 |
-
# chunks output directory
|
45 |
-
KH_CHUNKS_OUTPUT_DIR = KH_APP_DATA_DIR / "chunks_cache_dir"
|
46 |
-
KH_CHUNKS_OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
|
47 |
-
|
48 |
-
# zip output directory
|
49 |
-
KH_ZIP_OUTPUT_DIR = KH_APP_DATA_DIR / "zip_cache_dir"
|
50 |
-
KH_ZIP_OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
|
51 |
-
|
52 |
-
# zip input directory
|
53 |
-
KH_ZIP_INPUT_DIR = KH_APP_DATA_DIR / "zip_cache_dir_in"
|
54 |
-
KH_ZIP_INPUT_DIR.mkdir(parents=True, exist_ok=True)
|
55 |
-
|
56 |
-
# HF models can be big, let's store them in the app data directory so that it's easier
|
57 |
-
# for users to manage their storage.
|
58 |
-
# ref: https://huggingface.co/docs/huggingface_hub/en/guides/manage-cache
|
59 |
-
os.environ["HF_HOME"] = str(KH_APP_DATA_DIR / "huggingface")
|
60 |
-
os.environ["HF_HUB_CACHE"] = str(KH_APP_DATA_DIR / "huggingface")
|
61 |
-
|
62 |
-
# doc directory
|
63 |
-
KH_DOC_DIR = this_dir / "docs"
|
64 |
-
|
65 |
-
KH_MODE = "dev"
|
66 |
-
KH_FEATURE_USER_MANAGEMENT = False
|
67 |
-
KH_USER_CAN_SEE_PUBLIC = None
|
68 |
-
KH_FEATURE_USER_MANAGEMENT_ADMIN = str(
|
69 |
-
config("KH_FEATURE_USER_MANAGEMENT_ADMIN", default="admin")
|
70 |
-
)
|
71 |
-
KH_FEATURE_USER_MANAGEMENT_PASSWORD = str(
|
72 |
-
config("KH_FEATURE_USER_MANAGEMENT_PASSWORD", default="admin")
|
73 |
-
)
|
74 |
-
KH_ENABLE_ALEMBIC = False
|
75 |
-
KH_DATABASE = f"sqlite:///{KH_USER_DATA_DIR / 'sql.db'}"
|
76 |
-
KH_FILESTORAGE_PATH = str(KH_USER_DATA_DIR / "files")
|
77 |
-
|
78 |
-
KH_DOCSTORE = {
|
79 |
-
# "__type__": "kotaemon.storages.ElasticsearchDocumentStore",
|
80 |
-
# "__type__": "kotaemon.storages.SimpleFileDocumentStore",
|
81 |
-
"__type__": "kotaemon.storages.LanceDBDocumentStore",
|
82 |
-
"path": str(KH_USER_DATA_DIR / "docstore"),
|
83 |
-
}
|
84 |
-
KH_VECTORSTORE = {
|
85 |
-
# "__type__": "kotaemon.storages.LanceDBVectorStore",
|
86 |
-
"__type__": "kotaemon.storages.ChromaVectorStore",
|
87 |
-
# "__type__": "kotaemon.storages.MilvusVectorStore",
|
88 |
-
# "__type__": "kotaemon.storages.QdrantVectorStore",
|
89 |
-
"path": str(KH_USER_DATA_DIR / "vectorstore"),
|
90 |
-
}
|
91 |
-
KH_LLMS = {}
|
92 |
-
KH_EMBEDDINGS = {}
|
93 |
-
KH_RERANKINGS = {}
|
94 |
-
|
95 |
-
# populate options from config
|
96 |
-
if config("AZURE_OPENAI_API_KEY", default="") and config(
|
97 |
-
"AZURE_OPENAI_ENDPOINT", default=""
|
98 |
-
):
|
99 |
-
if config("AZURE_OPENAI_CHAT_DEPLOYMENT", default=""):
|
100 |
-
KH_LLMS["azure"] = {
|
101 |
-
"spec": {
|
102 |
-
"__type__": "kotaemon.llms.AzureChatOpenAI",
|
103 |
-
"temperature": 0,
|
104 |
-
"azure_endpoint": config("AZURE_OPENAI_ENDPOINT", default=""),
|
105 |
-
"api_key": config("AZURE_OPENAI_API_KEY", default=""),
|
106 |
-
"api_version": config("OPENAI_API_VERSION", default="")
|
107 |
-
or "2024-02-15-preview",
|
108 |
-
"azure_deployment": config("AZURE_OPENAI_CHAT_DEPLOYMENT", default=""),
|
109 |
-
"timeout": 20,
|
110 |
-
},
|
111 |
-
"default": False,
|
112 |
-
}
|
113 |
-
if config("AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT", default=""):
|
114 |
-
KH_EMBEDDINGS["azure"] = {
|
115 |
-
"spec": {
|
116 |
-
"__type__": "kotaemon.embeddings.AzureOpenAIEmbeddings",
|
117 |
-
"azure_endpoint": config("AZURE_OPENAI_ENDPOINT", default=""),
|
118 |
-
"api_key": config("AZURE_OPENAI_API_KEY", default=""),
|
119 |
-
"api_version": config("OPENAI_API_VERSION", default="")
|
120 |
-
or "2024-02-15-preview",
|
121 |
-
"azure_deployment": config(
|
122 |
-
"AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT", default=""
|
123 |
-
),
|
124 |
-
"timeout": 10,
|
125 |
-
},
|
126 |
-
"default": False,
|
127 |
-
}
|
128 |
-
|
129 |
-
if config("OPENAI_API_KEY", default=""):
|
130 |
-
KH_LLMS["openai"] = {
|
131 |
-
"spec": {
|
132 |
-
"__type__": "kotaemon.llms.ChatOpenAI",
|
133 |
-
"temperature": 0,
|
134 |
-
"base_url": config("OPENAI_API_BASE", default="")
|
135 |
-
or "https://api.openai.com/v1",
|
136 |
-
"api_key": config("OPENAI_API_KEY", default=""),
|
137 |
-
"model": config("OPENAI_CHAT_MODEL", default="gpt-3.5-turbo"),
|
138 |
-
"timeout": 20,
|
139 |
-
},
|
140 |
-
"default": True,
|
141 |
-
}
|
142 |
-
KH_EMBEDDINGS["openai"] = {
|
143 |
-
"spec": {
|
144 |
-
"__type__": "kotaemon.embeddings.OpenAIEmbeddings",
|
145 |
-
"base_url": config("OPENAI_API_BASE", default="https://api.openai.com/v1"),
|
146 |
-
"api_key": config("OPENAI_API_KEY", default=""),
|
147 |
-
"model": config(
|
148 |
-
"OPENAI_EMBEDDINGS_MODEL", default="text-embedding-ada-002"
|
149 |
-
),
|
150 |
-
"timeout": 10,
|
151 |
-
"context_length": 8191,
|
152 |
-
},
|
153 |
-
"default": True,
|
154 |
-
}
|
155 |
-
|
156 |
-
if config("LOCAL_MODEL", default=""):
|
157 |
-
KH_LLMS["ollama"] = {
|
158 |
-
"spec": {
|
159 |
-
"__type__": "kotaemon.llms.ChatOpenAI",
|
160 |
-
"base_url": "http://localhost:11434/v1/",
|
161 |
-
"model": config("LOCAL_MODEL", default="llama3.1:8b"),
|
162 |
-
"api_key": "ollama",
|
163 |
-
},
|
164 |
-
"default": False,
|
165 |
-
}
|
166 |
-
KH_EMBEDDINGS["ollama"] = {
|
167 |
-
"spec": {
|
168 |
-
"__type__": "kotaemon.embeddings.OpenAIEmbeddings",
|
169 |
-
"base_url": "http://localhost:11434/v1/",
|
170 |
-
"model": config("LOCAL_MODEL_EMBEDDINGS", default="nomic-embed-text"),
|
171 |
-
"api_key": "ollama",
|
172 |
-
},
|
173 |
-
"default": False,
|
174 |
-
}
|
175 |
-
|
176 |
-
KH_EMBEDDINGS["fast_embed"] = {
|
177 |
-
"spec": {
|
178 |
-
"__type__": "kotaemon.embeddings.FastEmbedEmbeddings",
|
179 |
-
"model_name": "BAAI/bge-base-en-v1.5",
|
180 |
-
},
|
181 |
-
"default": False,
|
182 |
-
}
|
183 |
-
|
184 |
-
# additional LLM configurations
|
185 |
-
KH_LLMS["claude"] = {
|
186 |
-
"spec": {
|
187 |
-
"__type__": "kotaemon.llms.chats.LCAnthropicChat",
|
188 |
-
"model_name": "claude-3-5-sonnet-20240620",
|
189 |
-
"api_key": "your-key",
|
190 |
-
},
|
191 |
-
"default": False,
|
192 |
-
}
|
193 |
-
KH_LLMS["gemini"] = {
|
194 |
-
"spec": {
|
195 |
-
"__type__": "kotaemon.llms.chats.LCGeminiChat",
|
196 |
-
"model_name": "gemini-1.5-pro",
|
197 |
-
"api_key": "your-key",
|
198 |
-
},
|
199 |
-
"default": False,
|
200 |
-
}
|
201 |
-
KH_LLMS["groq"] = {
|
202 |
-
"spec": {
|
203 |
-
"__type__": "kotaemon.llms.ChatOpenAI",
|
204 |
-
"base_url": "https://api.groq.com/openai/v1",
|
205 |
-
"model": "llama-3.1-8b-instant",
|
206 |
-
"api_key": "your-key",
|
207 |
-
},
|
208 |
-
"default": False,
|
209 |
-
}
|
210 |
-
KH_LLMS["cohere"] = {
|
211 |
-
"spec": {
|
212 |
-
"__type__": "kotaemon.llms.chats.LCCohereChat",
|
213 |
-
"model_name": "command-r-plus-08-2024",
|
214 |
-
"api_key": config("COHERE_API_KEY", default="your-key"),
|
215 |
-
},
|
216 |
-
"default": False,
|
217 |
-
}
|
218 |
-
|
219 |
-
# additional embeddings configurations
|
220 |
-
KH_EMBEDDINGS["cohere"] = {
|
221 |
-
"spec": {
|
222 |
-
"__type__": "kotaemon.embeddings.LCCohereEmbeddings",
|
223 |
-
"model": "embed-multilingual-v3.0",
|
224 |
-
"cohere_api_key": config("COHERE_API_KEY", default="your-key"),
|
225 |
-
"user_agent": "default",
|
226 |
-
},
|
227 |
-
"default": False,
|
228 |
-
}
|
229 |
-
# KH_EMBEDDINGS["huggingface"] = {
|
230 |
-
# "spec": {
|
231 |
-
# "__type__": "kotaemon.embeddings.LCHuggingFaceEmbeddings",
|
232 |
-
# "model_name": "sentence-transformers/all-mpnet-base-v2",
|
233 |
-
# },
|
234 |
-
# "default": False,
|
235 |
-
# }
|
236 |
-
|
237 |
-
# default reranking models
|
238 |
-
KH_RERANKINGS["cohere"] = {
|
239 |
-
"spec": {
|
240 |
-
"__type__": "kotaemon.rerankings.CohereReranking",
|
241 |
-
"model_name": "rerank-multilingual-v2.0",
|
242 |
-
"cohere_api_key": config("COHERE_API_KEY", default="your-key"),
|
243 |
-
},
|
244 |
-
"default": True,
|
245 |
-
}
|
246 |
-
|
247 |
-
KH_REASONINGS = [
|
248 |
-
"ktem.reasoning.simple.FullQAPipeline",
|
249 |
-
"ktem.reasoning.simple.FullDecomposeQAPipeline",
|
250 |
-
"ktem.reasoning.react.ReactAgentPipeline",
|
251 |
-
"ktem.reasoning.rewoo.RewooAgentPipeline",
|
252 |
-
]
|
253 |
-
KH_REASONINGS_USE_MULTIMODAL = False
|
254 |
-
KH_VLM_ENDPOINT = "{0}/openai/deployments/{1}/chat/completions?api-version={2}".format(
|
255 |
-
config("AZURE_OPENAI_ENDPOINT", default=""),
|
256 |
-
config("OPENAI_VISION_DEPLOYMENT_NAME", default="gpt-4o"),
|
257 |
-
config("OPENAI_API_VERSION", default=""),
|
258 |
-
)
|
259 |
-
|
260 |
-
|
261 |
-
SETTINGS_APP: dict[str, dict] = {}
|
262 |
-
|
263 |
-
|
264 |
-
SETTINGS_REASONING = {
|
265 |
-
"use": {
|
266 |
-
"name": "Reasoning options",
|
267 |
-
"value": None,
|
268 |
-
"choices": [],
|
269 |
-
"component": "radio",
|
270 |
-
},
|
271 |
-
"lang": {
|
272 |
-
"name": "Language",
|
273 |
-
"value": "en",
|
274 |
-
"choices": [("English", "en"), ("Japanese", "ja"), ("Vietnamese", "vi")],
|
275 |
-
"component": "dropdown",
|
276 |
-
},
|
277 |
-
"max_context_length": {
|
278 |
-
"name": "Max context length (LLM)",
|
279 |
-
"value": 32000,
|
280 |
-
"component": "number",
|
281 |
-
},
|
282 |
-
}
|
283 |
-
|
284 |
-
|
285 |
-
KH_INDEX_TYPES = [
|
286 |
-
"ktem.index.file.FileIndex",
|
287 |
-
"ktem.index.file.graph.GraphRAGIndex",
|
288 |
-
]
|
289 |
-
KH_INDICES = [
|
290 |
-
{
|
291 |
-
"name": "File",
|
292 |
-
"config": {
|
293 |
-
"supported_file_types": (
|
294 |
-
".png, .jpeg, .jpg, .tiff, .tif, .pdf, .xls, .xlsx, .doc, .docx, "
|
295 |
-
".pptx, .csv, .html, .mhtml, .txt, .md, .zip"
|
296 |
-
),
|
297 |
-
"private": False,
|
298 |
-
},
|
299 |
-
"index_type": "ktem.index.file.FileIndex",
|
300 |
-
},
|
301 |
-
{
|
302 |
-
"name": "GraphRAG",
|
303 |
-
"config": {
|
304 |
-
"supported_file_types": (
|
305 |
-
".png, .jpeg, .jpg, .tiff, .tif, .pdf, .xls, .xlsx, .doc, .docx, "
|
306 |
-
".pptx, .csv, .html, .mhtml, .txt, .md, .zip"
|
307 |
-
),
|
308 |
-
"private": False,
|
309 |
-
},
|
310 |
-
"index_type": "ktem.index.file.graph.GraphRAGIndex",
|
311 |
-
},
|
312 |
-
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|