Spaces:
Sleeping
Sleeping
fix
Browse files- 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=
|
| 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 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 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):
|