Spaces:
Running
on
T4
Running
on
T4
oceansweep
commited on
Commit
•
31334e0
1
Parent(s):
af712f6
Upload RAG_Libary_2.py
Browse files
App_Function_Libraries/RAG/RAG_Libary_2.py
CHANGED
@@ -127,13 +127,6 @@ def enhanced_rag_pipeline(query: str, api_choice: str, keywords: str = None) ->
|
|
127 |
|
128 |
# Combine results
|
129 |
all_results = vector_results + fts_results
|
130 |
-
# FIXME
|
131 |
-
if not all_results:
|
132 |
-
logging.info(f"No results found. Query: {query}, Keywords: {keywords}")
|
133 |
-
return {
|
134 |
-
"answer": "I couldn't find any relevant information based on your query and keywords.",
|
135 |
-
"context": ""
|
136 |
-
}
|
137 |
|
138 |
# FIXME - Apply Re-Ranking of results here
|
139 |
apply_re_ranking = False
|
@@ -147,10 +140,18 @@ def enhanced_rag_pipeline(query: str, api_choice: str, keywords: str = None) ->
|
|
147 |
# Generate answer using the selected API
|
148 |
answer = generate_answer(api_choice, context, query)
|
149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
return {
|
151 |
"answer": answer,
|
152 |
"context": context
|
153 |
}
|
|
|
154 |
except Exception as e:
|
155 |
logging.error(f"Error in enhanced_rag_pipeline: {str(e)}")
|
156 |
return {
|
|
|
127 |
|
128 |
# Combine results
|
129 |
all_results = vector_results + fts_results
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
|
131 |
# FIXME - Apply Re-Ranking of results here
|
132 |
apply_re_ranking = False
|
|
|
140 |
# Generate answer using the selected API
|
141 |
answer = generate_answer(api_choice, context, query)
|
142 |
|
143 |
+
if not all_results:
|
144 |
+
logging.info(f"No results found. Query: {query}, Keywords: {keywords}")
|
145 |
+
return {
|
146 |
+
"answer": "No relevant information based on your query and keywords were found in the database. Your query has been directly passed to the LLM, and here is its answer: \n\n" + answer,
|
147 |
+
"context": "No relevant information based on your query and keywords were found in the database. The only context used was your query: \n\n" + query
|
148 |
+
}
|
149 |
+
|
150 |
return {
|
151 |
"answer": answer,
|
152 |
"context": context
|
153 |
}
|
154 |
+
|
155 |
except Exception as e:
|
156 |
logging.error(f"Error in enhanced_rag_pipeline: {str(e)}")
|
157 |
return {
|