aadya1762 commited on
Commit
0248731
·
1 Parent(s): 3a14fb3
Files changed (1) hide show
  1. gemmademo/_chat.py +21 -28
gemmademo/_chat.py CHANGED
@@ -40,6 +40,7 @@ class GradioChat:
40
  def _load_task(self, task_name: str):
41
  """Loads the task dynamically when switching tasks."""
42
  return PromptManager(task=task_name)
 
43
 
44
  def _chat(self):
45
  def chat_fn(message, history, selected_model, selected_task):
@@ -67,26 +68,25 @@ class GradioChat:
67
  response_stream = self.model.generate_response(prompt)
68
  yield from response_stream
69
 
70
- # Examples for each task type
71
- examples = {
72
- "Question Answering": [
73
- "What is quantum computing?",
74
- "How do neural networks work?",
75
- "Explain climate change in simple terms.",
76
- ],
77
- "Text Generation": [
78
- "Once upon a time in a distant galaxy...",
79
- "The abandoned house at the end of the street had...",
80
- "In the year 2150, humanity discovered...",
81
- ],
82
- "Code Completion": [
83
- "def fibonacci(n):",
84
- "class BinarySearchInAList:",
85
- "async def fetch_data(url):",
86
- ],
87
- }
88
-
89
- def update_examples(task):
90
  return examples.get(task)
91
 
92
  with gr.Blocks() as demo:
@@ -126,17 +126,10 @@ class GradioChat:
126
 
127
  gr.Markdown("## Examples")
128
  examples_list = gr.Examples(
129
- examples=examples[self.current_task_name],
130
  inputs=chat_interface.textbox,
131
  )
132
 
133
- # Update examples when task changes
134
- task_dropdown.change(
135
- fn=update_examples,
136
- inputs=task_dropdown,
137
- outputs=examples_list,
138
- )
139
-
140
  demo.launch()
141
 
142
  def run(self):
 
40
  def _load_task(self, task_name: str):
41
  """Loads the task dynamically when switching tasks."""
42
  return PromptManager(task=task_name)
43
+
44
 
45
  def _chat(self):
46
  def chat_fn(message, history, selected_model, selected_task):
 
68
  response_stream = self.model.generate_response(prompt)
69
  yield from response_stream
70
 
71
+ def _get_examples(task):
72
+ # Examples for each task type
73
+ examples = {
74
+ "Question Answering": [
75
+ "What is quantum computing?",
76
+ "How do neural networks work?",
77
+ "Explain climate change in simple terms.",
78
+ ],
79
+ "Text Generation": [
80
+ "Once upon a time in a distant galaxy...",
81
+ "The abandoned house at the end of the street had...",
82
+ "In the year 2150, humanity discovered...",
83
+ ],
84
+ "Code Completion": [
85
+ "def fibonacci(n):",
86
+ "class BinarySearchInAList:",
87
+ "async def fetch_data(url):",
88
+ ],
89
+ }
 
90
  return examples.get(task)
91
 
92
  with gr.Blocks() as demo:
 
126
 
127
  gr.Markdown("## Examples")
128
  examples_list = gr.Examples(
129
+ examples=_get_examples(self.current_task_name),
130
  inputs=chat_interface.textbox,
131
  )
132
 
 
 
 
 
 
 
 
133
  demo.launch()
134
 
135
  def run(self):