agarwalamit081 commited on
Commit
ad2d8b8
·
verified ·
1 Parent(s): 35449f1

Update Gradio_UI.py

Browse files
Files changed (1) hide show
  1. Gradio_UI.py +5 -2
Gradio_UI.py CHANGED
@@ -141,11 +141,14 @@ def stream_to_gradio(
141
  # Extract the actual content from the final answer
142
  content = str(final)
143
  # Remove the wrapper if it exists (e.g., "FinalAnswerStep(final_answer='...')")
144
- if "final_answer=" in content:
145
  import re
146
- match = re.search(r"final_answer=['\"](.+)['\"]", content, re.DOTALL)
147
  if match:
148
  content = match.group(1)
 
 
 
149
  # Unescape newlines and other escape sequences
150
  content = content.encode().decode('unicode_escape')
151
 
 
141
  # Extract the actual content from the final answer
142
  content = str(final)
143
  # Remove the wrapper if it exists (e.g., "FinalAnswerStep(final_answer='...')")
144
+ if "final_answer=" in content or "FinalAnswerStep" in content:
145
  import re
146
+ match = re.search(r"final_answer=['\"](.+?)['\"](?:\)|$)", content, re.DOTALL)
147
  if match:
148
  content = match.group(1)
149
+ elif "final_answer='" in content:
150
+ # Alternative extraction if regex fails
151
+ content = content.split("final_answer='", 1)[1].rsplit("')", 1)[0]
152
  # Unescape newlines and other escape sequences
153
  content = content.encode().decode('unicode_escape')
154