Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -705,12 +705,7 @@ def answer_question_thread(user_question, chatbot,audio=None):
|
|
705 |
while iterations < max_iterations:
|
706 |
|
707 |
response = agent_executor.invoke({"input": user_question}, config={"callbacks": [langfuse_handler]}, early_stopping_method="generate")
|
708 |
-
|
709 |
-
if agent_executor.iterations >= agent_executor.max_iterations:
|
710 |
-
if agent_executor.history:
|
711 |
-
return agent_executor.history[-1].get("output") # Extract the last response from the history
|
712 |
-
|
713 |
-
|
714 |
|
715 |
#create_file_HF()
|
716 |
if isinstance(response, dict):
|
@@ -720,12 +715,12 @@ def answer_question_thread(user_question, chatbot,audio=None):
|
|
720 |
if "invalid" not in response_text.lower():
|
721 |
break
|
722 |
iterations += 1
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
|
730 |
if os.getenv("IMAGE_PATH") in response_text:
|
731 |
# Open the image file
|
|
|
705 |
while iterations < max_iterations:
|
706 |
|
707 |
response = agent_executor.invoke({"input": user_question}, config={"callbacks": [langfuse_handler]}, early_stopping_method="generate")
|
708 |
+
|
|
|
|
|
|
|
|
|
|
|
709 |
|
710 |
#create_file_HF()
|
711 |
if isinstance(response, dict):
|
|
|
715 |
if "invalid" not in response_text.lower():
|
716 |
break
|
717 |
iterations += 1
|
718 |
+
print("iterations::")
|
719 |
+
print(iterations)
|
720 |
+
if iterations == max_iterations:
|
721 |
+
print("final response::")
|
722 |
+
print(response)
|
723 |
+
return user_question , "Sorry, I couldn't complete your request" #"The agent could not generate a valid response within the iteration limit."
|
724 |
|
725 |
if os.getenv("IMAGE_PATH") in response_text:
|
726 |
# Open the image file
|