Spaces:
Sleeping
Sleeping
Update Gradio_UI.py
Browse files- Gradio_UI.py +18 -11
Gradio_UI.py
CHANGED
@@ -176,18 +176,25 @@ def stream_to_gradio(
|
|
176 |
|
177 |
|
178 |
class GradioUI:
|
179 |
-
|
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 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|