Spaces:
Build error
Build error
Update Gradio_UI.py
Browse files- Gradio_UI.py +3 -2
Gradio_UI.py
CHANGED
|
@@ -30,7 +30,7 @@ from app import agent # Импортируем объект агента
|
|
| 30 |
|
| 31 |
def gradio_search_jokes(word):
|
| 32 |
"""Wrapper function that sends the request to the agent and retrieves the joke and its audio."""
|
| 33 |
-
response = agent.run(word) # Отправляем запрос агенту
|
| 34 |
response_text = response.get("final_answer", "No response from agent.") # Получаем текст ответа
|
| 35 |
|
| 36 |
# Генерируем аудио
|
|
@@ -194,6 +194,7 @@ class GradioUI:
|
|
| 194 |
"""A one-line interface to launch your agent in Gradio"""
|
| 195 |
|
| 196 |
def __init__(self, agent: MultiStepAgent, file_upload_folder: str | None = None):
|
|
|
|
| 197 |
if not _is_package_available("gradio"):
|
| 198 |
raise ModuleNotFoundError(
|
| 199 |
"Please install 'gradio' extra to use the GradioUI: `pip install 'smolagents[gradio]'`"
|
|
@@ -296,7 +297,7 @@ class GradioUI:
|
|
| 296 |
output_text = gr.Textbox(label="Jokes Found") #added
|
| 297 |
output_audio = gr.Audio(label="Audio Pronunciation", type="filepath") #added
|
| 298 |
btn = gr.Button("Get Jokes") #added
|
| 299 |
-
btn.click(gradio_search_jokes, inputs=input_box, outputs=[output_text, output_audio]) #added
|
| 300 |
|
| 301 |
|
| 302 |
|
|
|
|
| 30 |
|
| 31 |
def gradio_search_jokes(word):
|
| 32 |
"""Wrapper function that sends the request to the agent and retrieves the joke and its audio."""
|
| 33 |
+
response = self.agent.run(word) # Отправляем запрос агенту
|
| 34 |
response_text = response.get("final_answer", "No response from agent.") # Получаем текст ответа
|
| 35 |
|
| 36 |
# Генерируем аудио
|
|
|
|
| 194 |
"""A one-line interface to launch your agent in Gradio"""
|
| 195 |
|
| 196 |
def __init__(self, agent: MultiStepAgent, file_upload_folder: str | None = None):
|
| 197 |
+
self.agent = agent # Сохраняем агента внутри класса
|
| 198 |
if not _is_package_available("gradio"):
|
| 199 |
raise ModuleNotFoundError(
|
| 200 |
"Please install 'gradio' extra to use the GradioUI: `pip install 'smolagents[gradio]'`"
|
|
|
|
| 297 |
output_text = gr.Textbox(label="Jokes Found") #added
|
| 298 |
output_audio = gr.Audio(label="Audio Pronunciation", type="filepath") #added
|
| 299 |
btn = gr.Button("Get Jokes") #added
|
| 300 |
+
btn.click(self.gradio_search_jokes, inputs=input_box, outputs=[output_text, output_audio]) #added
|
| 301 |
|
| 302 |
|
| 303 |
|