Spaces:
Sleeping
Sleeping
Commit
·
1731ed9
1
Parent(s):
c4ca074
Fix Gradio error
Browse files
app.py
CHANGED
|
@@ -7,6 +7,18 @@ from tools.final_answer import FinalAnswerTool
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
|
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
+
import Gradio_UI
|
| 11 |
+
_orig_handle = Gradio_UI.handle_agent_output_types
|
| 12 |
+
|
| 13 |
+
def _patched_handle(step):
|
| 14 |
+
# If step is a FinalAnswerStep, extract the inner .final_answer
|
| 15 |
+
if step.__class__.__name__ == 'FinalAnswerStep':
|
| 16 |
+
return step.final_answer
|
| 17 |
+
# otherwise, call the original
|
| 18 |
+
return _orig_handle(step)
|
| 19 |
+
|
| 20 |
+
Gradio_UI.handle_agent_output_types = _patched_handle
|
| 21 |
+
|
| 22 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 23 |
@tool
|
| 24 |
def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|