aadya1762 commited on
Commit
bb7bcb3
·
1 Parent(s): 2feb7f6
Files changed (1) hide show
  1. gemmademo/_chat.py +18 -15
gemmademo/_chat.py CHANGED
@@ -89,9 +89,13 @@ class GradioChat:
89
  }
90
  return examples.get(task)
91
 
 
 
 
 
92
  with gr.Blocks() as demo:
93
  with gr.Row():
94
- with gr.Column(scale=3):
95
  task_dropdown = gr.Dropdown(
96
  choices=self.task_options,
97
  value=self.current_task_name,
@@ -102,16 +106,6 @@ class GradioChat:
102
  value=self.current_model_name,
103
  label="Select Gemma Model",
104
  )
105
-
106
- chat_interface = gr.ChatInterface(
107
- chat_fn,
108
- additional_inputs=[model_dropdown, task_dropdown],
109
- textbox=gr.Textbox(
110
- placeholder="Ask me something...", container=False
111
- ),
112
- )
113
-
114
- with gr.Column(scale=1):
115
  gr.Markdown(
116
  """
117
  ## Tips
@@ -129,12 +123,21 @@ class GradioChat:
129
  examples=_get_examples(self.current_task_name),
130
  inputs=chat_interface.textbox,
131
  )
132
- examples_list.change(
133
- fn=_get_examples,
134
- inputs=self.current_task_name,
135
- outputs=examples_list,
136
  )
137
 
 
 
 
 
 
 
 
 
 
138
  demo.launch()
139
 
140
  def run(self):
 
89
  }
90
  return examples.get(task)
91
 
92
+ def _update_examples(task):
93
+ """Updates the examples based on the selected task."""
94
+ return gr.Dataset(samples=_get_examples(task))
95
+
96
  with gr.Blocks() as demo:
97
  with gr.Row():
98
+ with gr.Column(scale=1):
99
  task_dropdown = gr.Dropdown(
100
  choices=self.task_options,
101
  value=self.current_task_name,
 
106
  value=self.current_model_name,
107
  label="Select Gemma Model",
108
  )
 
 
 
 
 
 
 
 
 
 
109
  gr.Markdown(
110
  """
111
  ## Tips
 
123
  examples=_get_examples(self.current_task_name),
124
  inputs=chat_interface.textbox,
125
  )
126
+ task_dropdown.change(
127
+ _update_examples,
128
+ task_dropdown,
129
+ examples_list.dataset
130
  )
131
 
132
+ with gr.Column(scale=3):
133
+ chat_interface = gr.ChatInterface(
134
+ chat_fn,
135
+ additional_inputs=[model_dropdown, task_dropdown],
136
+ textbox=gr.Textbox(
137
+ placeholder="Ask me something...", container=False
138
+ ),
139
+ )
140
+
141
  demo.launch()
142
 
143
  def run(self):