uasername commited on
Commit
f054738
·
verified ·
1 Parent(s): fc5cfc2

Update Gradio_UI.py

Browse files
Files changed (1) hide show
  1. Gradio_UI.py +21 -9
Gradio_UI.py CHANGED
@@ -28,15 +28,15 @@ from smolagents.utils import _is_package_available
28
 
29
  # 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 = self.agent.run(word) # Отправляем запрос агенту
34
- response_text = response.get("final_answer", "No response from agent.") # Получаем текст ответа
35
 
36
- # Генерируем аудио
37
- audio_file = speak_text(response_text)
38
 
39
- return response_text, audio_file
40
 
41
 
42
 
@@ -191,10 +191,11 @@ def stream_to_gradio(
191
 
192
 
193
  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
- 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]'`"
@@ -205,6 +206,17 @@ class GradioUI:
205
  if not os.path.exists(file_upload_folder):
206
  os.mkdir(file_upload_folder)
207
 
 
 
 
 
 
 
 
 
 
 
 
208
  def interact_with_agent(self, prompt, messages):
209
  import gradio as gr
210
 
 
28
 
29
  # 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 = self.agent.run(word) # Отправляем запрос агенту
34
+ # response_text = response.get("final_answer", "No response from agent.") # Получаем текст ответа
35
 
36
+ # # Генерируем аудио
37
+ # audio_file = speak_text(response_text)
38
 
39
+ # return response_text, audio_file
40
 
41
 
42
 
 
191
 
192
 
193
  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
+ self.agent = agent # Передаём агента внутрь класса
198
+
199
  if not _is_package_available("gradio"):
200
  raise ModuleNotFoundError(
201
  "Please install 'gradio' extra to use the GradioUI: `pip install 'smolagents[gradio]'`"
 
206
  if not os.path.exists(file_upload_folder):
207
  os.mkdir(file_upload_folder)
208
 
209
+ def gradio_search_jokes(self, word): # Теперь это МЕТОД класса
210
+ """Wrapper function that sends the request to the agent and retrieves the joke and its audio."""
211
+ response = self.agent.run(word) # Используем self.agent
212
+ response_text = response.get("final_answer", "No response from agent.") # Получаем текст ответа
213
+
214
+ # Генерируем аудио
215
+ audio_file = speak_text(response_text)
216
+
217
+ return response_text, audio_file
218
+
219
+
220
  def interact_with_agent(self, prompt, messages):
221
  import gradio as gr
222