Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -23,6 +23,7 @@ def respond(
|
|
| 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,20 +80,10 @@ def respond(
|
|
| 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,21 +121,18 @@ seed_slider = gr.Slider(
|
|
| 130 |
label="Seed (-1 for random)"
|
| 131 |
)
|
| 132 |
|
| 133 |
-
#
|
| 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 |
-
|
| 147 |
-
Model text box with that selection automatically.
|
| 148 |
"""
|
| 149 |
print(f"Featured model selected: {selected}")
|
| 150 |
return selected
|
|
@@ -158,7 +146,7 @@ demo = gr.ChatInterface(
|
|
| 158 |
top_p_slider,
|
| 159 |
frequency_penalty_slider,
|
| 160 |
seed_slider,
|
| 161 |
-
custom_model_box,
|
| 162 |
],
|
| 163 |
fill_height=True,
|
| 164 |
chatbot=chatbot,
|
|
@@ -168,9 +156,6 @@ print("ChatInterface object created.")
|
|
| 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...",
|
|
|
|
| 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 |
|
| 81 |
# GRADIO UI
|
| 82 |
|
| 83 |
+
chatbot = gr.Chatbot(height=600, show_copy_button=True, placeholder="Select a model and begin chatting", likeable=True, layout="panel")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
print("Chatbot interface created.")
|
| 85 |
|
| 86 |
+
system_message_box = gr.Textbox(value="", placeholder="You are a helpful assistant.", label="System Prompt")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
max_tokens_slider = gr.Slider(
|
| 89 |
minimum=1,
|
|
|
|
| 121 |
label="Seed (-1 for random)"
|
| 122 |
)
|
| 123 |
|
| 124 |
+
# The custom_model_box is what the respond function sees as "custom_model"
|
| 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 from the 'Featured Models' radio.
|
| 135 |
+
We will update the Custom Model text box with that selection automatically.
|
|
|
|
| 136 |
"""
|
| 137 |
print(f"Featured model selected: {selected}")
|
| 138 |
return selected
|
|
|
|
| 146 |
top_p_slider,
|
| 147 |
frequency_penalty_slider,
|
| 148 |
seed_slider,
|
| 149 |
+
custom_model_box,
|
| 150 |
],
|
| 151 |
fill_height=True,
|
| 152 |
chatbot=chatbot,
|
|
|
|
| 156 |
|
| 157 |
with demo:
|
| 158 |
with gr.Accordion("Model Selection", open=False):
|
|
|
|
|
|
|
|
|
|
| 159 |
model_search_box = gr.Textbox(
|
| 160 |
label="Filter Models",
|
| 161 |
placeholder="Search for a featured model...",
|