Spaces:
Sleeping
Sleeping
add some error handling
Browse files
app.py
CHANGED
@@ -205,8 +205,11 @@ def reasoner(query: str, documents: list[str], llm_client: Any):
|
|
205 |
llm_response = llm_client.run_inference(prompt)
|
206 |
|
207 |
answer_dict = safe_parse_json(llm_response)
|
208 |
-
|
209 |
-
|
|
|
|
|
|
|
210 |
|
211 |
for chunk in message.split():
|
212 |
text += chunk + " "
|
@@ -260,6 +263,8 @@ if prompt := st.chat_input("Type here"):
|
|
260 |
assistant_response = f'The claim is CORRECT because {reasoning}'
|
261 |
elif decision.lower() == 'contradict':
|
262 |
assistant_response = f'The claim is INCORRECT because {reasoning}'
|
|
|
|
|
263 |
|
264 |
# Simulate stream of response with milliseconds delay
|
265 |
for chunk in assistant_response.split():
|
|
|
205 |
llm_response = llm_client.run_inference(prompt)
|
206 |
|
207 |
answer_dict = safe_parse_json(llm_response)
|
208 |
+
try:
|
209 |
+
decision = answer_dict.get("decision", "")
|
210 |
+
reasoning = answer_dict.get("reasoning", "")
|
211 |
+
except:
|
212 |
+
print(f"Error with parsing the returned {answer_dict}")
|
213 |
|
214 |
for chunk in message.split():
|
215 |
text += chunk + " "
|
|
|
263 |
assistant_response = f'The claim is CORRECT because {reasoning}'
|
264 |
elif decision.lower() == 'contradict':
|
265 |
assistant_response = f'The claim is INCORRECT because {reasoning}'
|
266 |
+
else:
|
267 |
+
assistant_response = f'Sorry, the query failed due to an issue with connecting to the LLM service.'
|
268 |
|
269 |
# Simulate stream of response with milliseconds delay
|
270 |
for chunk in assistant_response.split():
|