Spaces:
Sleeping
Sleeping
model select
Browse files- 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 |
-
|
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 |
-
#
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
'mistrallite.Q4_K_M.gguf',
|
95 |
-
],
|
96 |
-
value="qwen2-0_5b-instruct-q4_k_m.gguf",
|
97 |
-
label="Model"
|
98 |
-
)
|
99 |
|
100 |
-
#
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
chatbot=gr.Chatbot(
|
137 |
-
scale=1,
|
138 |
-
likeable=False,
|
139 |
-
show_copy_button=True
|
140 |
)
|
141 |
-
|
|
|
|
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()
|