Tbaberca commited on
Commit
2c8a37c
·
verified ·
1 Parent(s): 2c82301

Update Gradio_UI.py

Browse files
Files changed (1) hide show
  1. Gradio_UI.py +18 -11
Gradio_UI.py CHANGED
@@ -176,18 +176,25 @@ def stream_to_gradio(
176
 
177
 
178
  class GradioUI:
179
- """A one-line interface to launch your agent in Gradio"""
180
-
181
- def __init__(self, agent: MultiStepAgent, file_upload_folder: str | None = None):
182
- if not _is_package_available("gradio"):
183
- raise ModuleNotFoundError(
184
- "Please install 'gradio' extra to use the GradioUI: `pip install 'smolagents[gradio]'`"
185
- )
186
  self.agent = agent
187
- self.file_upload_folder = file_upload_folder
188
- if self.file_upload_folder is not None:
189
- if not os.path.exists(file_upload_folder):
190
- os.mkdir(file_upload_folder)
 
 
 
 
 
 
 
 
 
 
 
 
 
191
 
192
  def interact_with_agent(self, prompt, messages):
193
  import gradio as gr
 
176
 
177
 
178
  class GradioUI:
179
+ def __init__(self, agent):
 
 
 
 
 
 
180
  self.agent = agent
181
+
182
+ def launch(self, share=False, **kwargs):
183
+ import gradio as gr
184
+
185
+ # Your interface setup here
186
+ with gr.Blocks() as demo:
187
+ gr.Markdown("### Welcome to the AI Agent UI")
188
+ inp = gr.Textbox(label="Input")
189
+ out = gr.Textbox(label="Output")
190
+
191
+ def respond(message):
192
+ return self.agent.run(message)
193
+
194
+ btn = gr.Button("Submit")
195
+ btn.click(fn=respond, inputs=inp, outputs=out)
196
+
197
+ demo.launch(debug=True, share=share, **kwargs)
198
 
199
  def interact_with_agent(self, prompt, messages):
200
  import gradio as gr