Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -40,48 +40,48 @@ def invoke(openai_api_key,
|
|
40 |
|
41 |
inference_result = ""
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
|
|
|
|
77 |
|
78 |
print("###")
|
79 |
print(inference_result)
|
80 |
print("###")
|
81 |
|
82 |
return inference_result
|
83 |
-
# except Exception as e:
|
84 |
-
# raise gr.Error(e)
|
85 |
|
86 |
gr.close_all()
|
87 |
|
|
|
40 |
|
41 |
inference_result = ""
|
42 |
|
43 |
+
try:
|
44 |
+
if (RAG_INGESTION):
|
45 |
+
return rag_ingestion(collection)
|
46 |
+
elif rag_option == RAG_OFF:
|
47 |
+
inference_result = inference(
|
48 |
+
openai_api_key,
|
49 |
+
prompt
|
50 |
+
)
|
51 |
+
elif rag_option == RAG_NAIVE:
|
52 |
+
retrieval_result = rag_retrieval_naive(
|
53 |
+
openai_api_key,
|
54 |
+
prompt,
|
55 |
+
db,
|
56 |
+
collection
|
57 |
+
)
|
58 |
+
inference_result = rag_inference(
|
59 |
+
openai_api_key,
|
60 |
+
prompt,
|
61 |
+
retrieval_result
|
62 |
+
)
|
63 |
+
elif rag_option == RAG_ADVANCED:
|
64 |
+
retrieval_result = rag_retrieval_advanced(
|
65 |
+
openai_api_key,
|
66 |
+
prompt,
|
67 |
+
accomodates,
|
68 |
+
bedrooms,
|
69 |
+
db,
|
70 |
+
collection
|
71 |
+
)
|
72 |
+
inference_result = rag_inference(
|
73 |
+
openai_api_key,
|
74 |
+
prompt,
|
75 |
+
retrieval_result
|
76 |
+
)
|
77 |
+
except Exception as e:
|
78 |
+
raise gr.Error(e)
|
79 |
|
80 |
print("###")
|
81 |
print(inference_result)
|
82 |
print("###")
|
83 |
|
84 |
return inference_result
|
|
|
|
|
85 |
|
86 |
gr.close_all()
|
87 |
|