Commit
·
1f555c8
1
Parent(s):
a0b3a97
test
Browse files- Gradio_UI.py +13 -1
Gradio_UI.py
CHANGED
|
@@ -23,6 +23,7 @@ from smolagents.agent_types import AgentAudio, AgentImage, AgentText, handle_age
|
|
| 23 |
from smolagents.agents import ActionStep, MultiStepAgent
|
| 24 |
from smolagents.memory import MemoryStep
|
| 25 |
from smolagents.utils import _is_package_available
|
|
|
|
| 26 |
|
| 27 |
|
| 28 |
def pull_messages_from_step(
|
|
@@ -258,6 +259,17 @@ class GradioUI:
|
|
| 258 |
"",
|
| 259 |
)
|
| 260 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 261 |
def launch(self, **kwargs):
|
| 262 |
import gradio as gr
|
| 263 |
examples = [
|
|
@@ -292,7 +304,7 @@ class GradioUI:
|
|
| 292 |
# Description
|
| 293 |
examples=examples, # Example inputs
|
| 294 |
)
|
| 295 |
-
chatbot.example_select(self.
|
| 296 |
# If an upload folder is provided, enable the upload feature
|
| 297 |
if self.file_upload_folder is not None:
|
| 298 |
upload_file = gr.File(label="Upload a file")
|
|
|
|
| 23 |
from smolagents.agents import ActionStep, MultiStepAgent
|
| 24 |
from smolagents.memory import MemoryStep
|
| 25 |
from smolagents.utils import _is_package_available
|
| 26 |
+
import gradio as gr
|
| 27 |
|
| 28 |
|
| 29 |
def pull_messages_from_step(
|
|
|
|
| 259 |
"",
|
| 260 |
)
|
| 261 |
|
| 262 |
+
def append_example_message(x: gr.SelectData, history):
|
| 263 |
+
if x.value["text"] is not None:
|
| 264 |
+
history.append((x.value["text"], None))
|
| 265 |
+
if "files" in x.value:
|
| 266 |
+
if isinstance(x.value["files"], list):
|
| 267 |
+
for file in x.value["files"]:
|
| 268 |
+
history.append((file, None))
|
| 269 |
+
else:
|
| 270 |
+
history.append((x.value["files"], None))
|
| 271 |
+
return history
|
| 272 |
+
|
| 273 |
def launch(self, **kwargs):
|
| 274 |
import gradio as gr
|
| 275 |
examples = [
|
|
|
|
| 304 |
# Description
|
| 305 |
examples=examples, # Example inputs
|
| 306 |
)
|
| 307 |
+
chatbot.example_select(self.append_example_message, [chatbot], [chatbot]).then(self.interact_with_agent, [stored_messages, chatbot], [chatbot])
|
| 308 |
# If an upload folder is provided, enable the upload feature
|
| 309 |
if self.file_upload_folder is not None:
|
| 310 |
upload_file = gr.File(label="Upload a file")
|