umarigan commited on
Commit
cb6cd4f
·
verified ·
1 Parent(s): b53c68b

Update app.py

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