Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -23,7 +23,6 @@ def respond(
|
|
23 |
seed,
|
24 |
custom_model
|
25 |
):
|
26 |
-
|
27 |
print(f"Received message: {message}")
|
28 |
print(f"History: {history}")
|
29 |
print(f"System message: {system_message}")
|
@@ -80,10 +79,20 @@ def respond(
|
|
80 |
|
81 |
# GRADIO UI
|
82 |
|
83 |
-
chatbot = gr.Chatbot(
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
print("Chatbot interface created.")
|
85 |
|
86 |
-
system_message_box = gr.Textbox(
|
|
|
|
|
|
|
|
|
87 |
|
88 |
max_tokens_slider = gr.Slider(
|
89 |
minimum=1,
|
@@ -121,18 +130,21 @@ seed_slider = gr.Slider(
|
|
121 |
label="Seed (-1 for random)"
|
122 |
)
|
123 |
|
124 |
-
#
|
125 |
custom_model_box = gr.Textbox(
|
126 |
value="",
|
127 |
label="Custom Model",
|
128 |
info="(Optional) Provide a custom Hugging Face model path. Overrides any selected featured model.",
|
129 |
-
placeholder="meta-llama/Llama-3.3-70B-Instruct"
|
|
|
130 |
)
|
|
|
131 |
|
132 |
def set_custom_model_from_radio(selected):
|
133 |
"""
|
134 |
-
This function will get triggered whenever someone picks a model
|
135 |
-
We will update the Custom
|
|
|
136 |
"""
|
137 |
print(f"Featured model selected: {selected}")
|
138 |
return selected
|
@@ -146,6 +158,7 @@ demo = gr.ChatInterface(
|
|
146 |
top_p_slider,
|
147 |
frequency_penalty_slider,
|
148 |
seed_slider,
|
|
|
149 |
],
|
150 |
fill_height=True,
|
151 |
chatbot=chatbot,
|
@@ -155,9 +168,9 @@ print("ChatInterface object created.")
|
|
155 |
|
156 |
with demo:
|
157 |
with gr.Accordion("Model Selection", open=False):
|
158 |
-
#
|
159 |
-
custom_model_box
|
160 |
-
|
161 |
model_search_box = gr.Textbox(
|
162 |
label="Filter Models",
|
163 |
placeholder="Search for a featured model...",
|
@@ -218,4 +231,4 @@ print("Gradio interface initialized.")
|
|
218 |
|
219 |
if __name__ == "__main__":
|
220 |
print("Launching the demo application.")
|
221 |
-
demo.
|
|
|
23 |
seed,
|
24 |
custom_model
|
25 |
):
|
|
|
26 |
print(f"Received message: {message}")
|
27 |
print(f"History: {history}")
|
28 |
print(f"System message: {system_message}")
|
|
|
79 |
|
80 |
# GRADIO UI
|
81 |
|
82 |
+
chatbot = gr.Chatbot(
|
83 |
+
height=600,
|
84 |
+
show_copy_button=True,
|
85 |
+
placeholder="Select a model and begin chatting",
|
86 |
+
likeable=True,
|
87 |
+
layout="panel",
|
88 |
+
)
|
89 |
print("Chatbot interface created.")
|
90 |
|
91 |
+
system_message_box = gr.Textbox(
|
92 |
+
value="",
|
93 |
+
placeholder="You are a helpful assistant.",
|
94 |
+
label="System Prompt"
|
95 |
+
)
|
96 |
|
97 |
max_tokens_slider = gr.Slider(
|
98 |
minimum=1,
|
|
|
130 |
label="Seed (-1 for random)"
|
131 |
)
|
132 |
|
133 |
+
# Make sure it's interactive=True so the user can type into it
|
134 |
custom_model_box = gr.Textbox(
|
135 |
value="",
|
136 |
label="Custom Model",
|
137 |
info="(Optional) Provide a custom Hugging Face model path. Overrides any selected featured model.",
|
138 |
+
placeholder="meta-llama/Llama-3.3-70B-Instruct",
|
139 |
+
interactive=True
|
140 |
)
|
141 |
+
print("Custom model box created.")
|
142 |
|
143 |
def set_custom_model_from_radio(selected):
|
144 |
"""
|
145 |
+
This function will get triggered whenever someone picks a model
|
146 |
+
from the 'Featured Models' radio. We will update the Custom
|
147 |
+
Model text box with that selection automatically.
|
148 |
"""
|
149 |
print(f"Featured model selected: {selected}")
|
150 |
return selected
|
|
|
158 |
top_p_slider,
|
159 |
frequency_penalty_slider,
|
160 |
seed_slider,
|
161 |
+
custom_model_box, # Still fed into the respond function
|
162 |
],
|
163 |
fill_height=True,
|
164 |
chatbot=chatbot,
|
|
|
168 |
|
169 |
with demo:
|
170 |
with gr.Accordion("Model Selection", open=False):
|
171 |
+
# Place the custom_model_box at the top here
|
172 |
+
custom_model_box
|
173 |
+
|
174 |
model_search_box = gr.Textbox(
|
175 |
label="Filter Models",
|
176 |
placeholder="Search for a featured model...",
|
|
|
231 |
|
232 |
if __name__ == "__main__":
|
233 |
print("Launching the demo application.")
|
234 |
+
demo.Launch()
|