TobDeBer commited on
Commit
c64c2a3
·
1 Parent(s): 23c2ad6

model select

Browse files
Files changed (1) hide show
  1. app_local.py +56 -53
app_local.py CHANGED
@@ -12,16 +12,27 @@ import gradio as gr
12
  llm = None
13
  llm_model = None
14
 
 
 
 
 
 
 
 
 
 
 
 
15
  def respond(
16
  message,
17
  history: list[tuple[str, str]],
18
- selected_model, # This is now a parameter received from the interface
19
- system_message,
20
  max_tokens,
21
  temperature,
22
  top_p,
23
  top_k,
24
  repeat_penalty,
 
25
  ):
26
  chat_template = MessagesFormatterType.GEMMA_2
27
 
@@ -86,56 +97,48 @@ def respond(
86
  description = """<p align="center">Defaults to Qwen 500M</p>
87
  """
88
 
89
- # Dropdown for Model Selection
90
- model_dropdown = gr.Dropdown(
91
- [
92
- 'qwen2-0_5b-instruct-q4_k_m.gguf',
93
- 'qwen2_500m.gguf',
94
- 'mistrallite.Q4_K_M.gguf',
95
- ],
96
- value="qwen2-0_5b-instruct-q4_k_m.gguf",
97
- label="Model"
98
- )
99
 
100
- # Create the main chat interface
101
- demo = gr.ChatInterface(
102
- respond,
103
- additional_inputs=[
104
- model_dropdown, # Pass the selected model from Dropdown
105
- gr.Textbox(value="You are a helpful assistant.", label="System message"),
106
- gr.Slider(minimum=1, maximum=4096, value=2048, step=1, label="Max tokens"),
107
- gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
108
- gr.Slider(
109
- minimum=0.1,
110
- maximum=1.0,
111
- value=0.95,
112
- step=0.05,
113
- label="Top-p",
114
- ),
115
- gr.Slider(
116
- minimum=0,
117
- maximum=100,
118
- value=40,
119
- step=1,
120
- label="Top-k",
121
- ),
122
- gr.Slider(
123
- minimum=0.0,
124
- maximum=2.0,
125
- value=1.1,
126
- step=0.1,
127
- label="Repetition penalty",
128
- ),
129
- ],
130
- retry_btn="Retry",
131
- undo_btn="Undo",
132
- clear_btn="Clear",
133
- submit_btn="Send",
134
- title="Chat with Qwen 2 and friends using llama.cpp",
135
- description=description,
136
- chatbot=gr.Chatbot(
137
- scale=1,
138
- likeable=False,
139
- show_copy_button=True
140
  )
141
- ).launch()
 
 
12
  llm = None
13
  llm_model = None
14
 
15
+ # Dropdown for Model Selection
16
+ model_dropdown = gr.Dropdown(
17
+ [
18
+ 'qwen2-0_5b-instruct-q4_k_m.gguf',
19
+ 'qwen2_500m.gguf',
20
+ 'mistrallite.Q4_K_M.gguf',
21
+ ],
22
+ value="qwen2-0_5b-instruct-q4_k_m.gguf",
23
+ label="Model"
24
+ )
25
+
26
  def respond(
27
  message,
28
  history: list[tuple[str, str]],
29
+ system_message,
 
30
  max_tokens,
31
  temperature,
32
  top_p,
33
  top_k,
34
  repeat_penalty,
35
+ selected_model, # This is now a parameter received from the interface
36
  ):
37
  chat_template = MessagesFormatterType.GEMMA_2
38
 
 
97
  description = """<p align="center">Defaults to Qwen 500M</p>
98
  """
99
 
100
+ # Create the Gradio interface
101
+ with gr.Blocks() as demo: # Create a Gradio Blocks context
102
+
103
+ # Model selection dropdown above the chat
104
+ model_dropdown.render()
 
 
 
 
 
105
 
106
+ # Main chat interface
107
+ chat_interface = gr.ChatInterface(
108
+ respond,
109
+ additional_inputs=[
110
+ gr.Textbox(value="You are a helpful assistant.", label="System message"),
111
+ gr.Slider(minimum=1, maximum=4096, value=2048, step=1, label="Max tokens"),
112
+ gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
113
+ gr.Slider(
114
+ minimum=0.1,
115
+ maximum=1.0,
116
+ value=0.95,
117
+ step=0.05,
118
+ label="Top-p",
119
+ ),
120
+ gr.Slider(
121
+ minimum=0,
122
+ maximum=100,
123
+ value=40,
124
+ step=1,
125
+ label="Top-k",
126
+ ),
127
+ gr.Slider(
128
+ minimum=0.0,
129
+ maximum=2.0,
130
+ value=1.1,
131
+ step=0.1,
132
+ label="Repetition penalty",
133
+ ),
134
+ model_dropdown # Pass the dropdown directly
135
+ ],
136
+ retry_btn="Retry",
137
+ undo_btn="Undo",
138
+ clear_btn="Clear",
139
+ submit_btn="Send",
140
+ title="Chat with Qwen 2 and friends using llama.cpp",
141
+ description=description,
 
 
 
 
142
  )
143
+
144
+ demo.queue().launch()