jamin3000 commited on
Commit
2151c23
·
verified ·
1 Parent(s): 3f5e9d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -5
app.py CHANGED
@@ -1,7 +1,43 @@
1
- from fastapi import FastAPI
2
 
3
- app = FastAPI()
4
 
5
- @app.get("/")
6
- def greet_json():
7
- return {"Hello": "World!"}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ )