Spaces:
Paused
Paused
Shreyas094
commited on
Commit
•
9a7af34
1
Parent(s):
096249d
Update app.py
Browse files
app.py
CHANGED
@@ -279,6 +279,9 @@ def ask_question(question, temperature, top_p, repetition_penalty, web_search, c
|
|
279 |
|
280 |
contextualized_question, topics, entity_tracker = chatbot.process_question(question)
|
281 |
|
|
|
|
|
|
|
282 |
if web_search:
|
283 |
search_results = google_search(contextualized_question)
|
284 |
all_answers = []
|
@@ -315,7 +318,7 @@ def ask_question(question, temperature, top_p, repetition_penalty, web_search, c
|
|
315 |
conv_context=chatbot.get_context(),
|
316 |
question=question,
|
317 |
topics=", ".join(topics),
|
318 |
-
entities=json.dumps(
|
319 |
)
|
320 |
|
321 |
full_response = generate_chunked_response(model, formatted_prompt)
|
@@ -341,9 +344,7 @@ def ask_question(question, temperature, top_p, repetition_penalty, web_search, c
|
|
341 |
|
342 |
except Exception as e:
|
343 |
print(f"Error in ask_question (attempt {attempt + 1}): {e}")
|
344 |
-
if
|
345 |
-
print(f"Reducing context length for next attempt")
|
346 |
-
elif attempt == max_attempts - 1:
|
347 |
all_answers.append(f"I apologize, but I'm having trouble processing the query due to its length or complexity.")
|
348 |
|
349 |
answer = "\n\n".join(all_answers)
|
|
|
279 |
|
280 |
contextualized_question, topics, entity_tracker = chatbot.process_question(question)
|
281 |
|
282 |
+
# Convert sets to lists in entity_tracker
|
283 |
+
serializable_entity_tracker = {k: list(v) for k, v in entity_tracker.items()}
|
284 |
+
|
285 |
if web_search:
|
286 |
search_results = google_search(contextualized_question)
|
287 |
all_answers = []
|
|
|
318 |
conv_context=chatbot.get_context(),
|
319 |
question=question,
|
320 |
topics=", ".join(topics),
|
321 |
+
entities=json.dumps(serializable_entity_tracker)
|
322 |
)
|
323 |
|
324 |
full_response = generate_chunked_response(model, formatted_prompt)
|
|
|
344 |
|
345 |
except Exception as e:
|
346 |
print(f"Error in ask_question (attempt {attempt + 1}): {e}")
|
347 |
+
if attempt == max_attempts - 1:
|
|
|
|
|
348 |
all_answers.append(f"I apologize, but I'm having trouble processing the query due to its length or complexity.")
|
349 |
|
350 |
answer = "\n\n".join(all_answers)
|