Spaces:
Sleeping
Sleeping
Tadashi
commited on
Commit
•
437f13f
1
Parent(s):
6dd314c
fix: update default settings
Browse files- Dockerfile +1 -0
- app.py +43 -0
- flowsettings.py +1 -1
Dockerfile
CHANGED
@@ -8,6 +8,7 @@ USER user
|
|
8 |
WORKDIR /app
|
9 |
|
10 |
COPY flowsettings.py /app
|
|
|
11 |
|
12 |
ENV GRADIO_SERVER_NAME=0.0.0.0
|
13 |
ENTRYPOINT ["python", "app.py"]
|
|
|
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"]
|
app.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
+
from theflow.settings import settings as flowsettings
|
4 |
+
|
5 |
+
KH_APP_DATA_DIR = getattr(flowsettings, "KH_APP_DATA_DIR", ".")
|
6 |
+
GRADIO_TEMP_DIR = os.getenv("GRADIO_TEMP_DIR", None)
|
7 |
+
# override GRADIO_TEMP_DIR if it's not set
|
8 |
+
if GRADIO_TEMP_DIR is None:
|
9 |
+
GRADIO_TEMP_DIR = os.path.join(KH_APP_DATA_DIR, "gradio_tmp")
|
10 |
+
os.environ["GRADIO_TEMP_DIR"] = GRADIO_TEMP_DIR
|
11 |
+
|
12 |
+
|
13 |
+
## monkey patching default settings
|
14 |
+
from ktem.index.file.pipelines import DocumentRetrievalPipeline
|
15 |
+
|
16 |
+
original_settings = DocumentRetrievalPipeline.get_user_settings
|
17 |
+
|
18 |
+
def retrieval_default_settings():
|
19 |
+
print("Using custom default settings")
|
20 |
+
settings = original_settings()
|
21 |
+
settings["use_llm_reranking"] = {
|
22 |
+
"name": "Use LLM relevant scoring",
|
23 |
+
"value": False,
|
24 |
+
"choices": [True, False],
|
25 |
+
"component": "checkbox",
|
26 |
+
}
|
27 |
+
return settings
|
28 |
+
|
29 |
+
DocumentRetrievalPipeline.get_user_settings = retrieval_default_settings
|
30 |
+
|
31 |
+
|
32 |
+
from ktem.main import App # noqa
|
33 |
+
|
34 |
+
app = App()
|
35 |
+
demo = app.make()
|
36 |
+
demo.queue().launch(
|
37 |
+
favicon_path=app._favicon,
|
38 |
+
inbrowser=True,
|
39 |
+
allowed_paths=[
|
40 |
+
"libs/ktem/ktem/assets",
|
41 |
+
GRADIO_TEMP_DIR,
|
42 |
+
],
|
43 |
+
)
|
flowsettings.py
CHANGED
@@ -219,7 +219,7 @@ KH_LLMS["cohere"] = {
|
|
219 |
KH_EMBEDDINGS["cohere"] = {
|
220 |
"spec": {
|
221 |
"__type__": "kotaemon.embeddings.LCCohereEmbeddings",
|
222 |
-
"model": "embed-multilingual-
|
223 |
"cohere_api_key": "your-key",
|
224 |
"user_agent": "default",
|
225 |
},
|
|
|
219 |
KH_EMBEDDINGS["cohere"] = {
|
220 |
"spec": {
|
221 |
"__type__": "kotaemon.embeddings.LCCohereEmbeddings",
|
222 |
+
"model": "embed-multilingual-v3.0",
|
223 |
"cohere_api_key": "your-key",
|
224 |
"user_agent": "default",
|
225 |
},
|