Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -67,50 +67,6 @@ example_usage = """
|
|
| 67 |
- Example: "Get the EUR to GBP rate.
|
| 68 |
"""
|
| 69 |
|
| 70 |
-
# Extend the GradioUI class to include the example usage
|
| 71 |
-
class CustomGradioUI(GradioUI):
|
| 72 |
-
def __init__(self, agent, description: str = "", **kwargs):
|
| 73 |
-
super().__init__(agent, **kwargs)
|
| 74 |
-
self.description = description
|
| 75 |
-
|
| 76 |
-
def launch(self, **kwargs):
|
| 77 |
-
import gradio as gr
|
| 78 |
-
|
| 79 |
-
with gr.Blocks(fill_height=True) as demo:
|
| 80 |
-
# Add the description as a Markdown component
|
| 81 |
-
if self.description:
|
| 82 |
-
gr.Markdown(self.description)
|
| 83 |
-
|
| 84 |
-
# Add the existing chatbot and input components
|
| 85 |
-
stored_messages = gr.State([])
|
| 86 |
-
file_uploads_log = gr.State([])
|
| 87 |
-
chatbot = gr.Chatbot(
|
| 88 |
-
label="Agent",
|
| 89 |
-
type="messages",
|
| 90 |
-
avatar_images=(
|
| 91 |
-
None,
|
| 92 |
-
"https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/communication/Alfred.png",
|
| 93 |
-
),
|
| 94 |
-
resizeable=True,
|
| 95 |
-
scale=1,
|
| 96 |
-
)
|
| 97 |
-
# If an upload folder is provided, enable the upload feature
|
| 98 |
-
if self.file_upload_folder is not None:
|
| 99 |
-
upload_file = gr.File(label="Upload a file")
|
| 100 |
-
upload_status = gr.Textbox(label="Upload Status", interactive=False, visible=False)
|
| 101 |
-
upload_file.change(
|
| 102 |
-
self.upload_file,
|
| 103 |
-
[upload_file, file_uploads_log],
|
| 104 |
-
[upload_status, file_uploads_log],
|
| 105 |
-
)
|
| 106 |
-
text_input = gr.Textbox(lines=1, label="Chat Message")
|
| 107 |
-
text_input.submit(
|
| 108 |
-
self.log_user_message,
|
| 109 |
-
[text_input, file_uploads_log],
|
| 110 |
-
[stored_messages, text_input],
|
| 111 |
-
).then(self.interact_with_agent, [stored_messages, chatbot], [chatbot])
|
| 112 |
-
|
| 113 |
-
demo.launch(debug=True, share=True, **kwargs)
|
| 114 |
|
| 115 |
# Launch the Gradio UI with the example usage
|
| 116 |
-
CustomGradioUI(agent
|
|
|
|
| 67 |
- Example: "Get the EUR to GBP rate.
|
| 68 |
"""
|
| 69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
|
| 71 |
# Launch the Gradio UI with the example usage
|
| 72 |
+
CustomGradioUI(agent).launch()
|