Spaces:
Running
Running
UI updates
Browse files
app.py
CHANGED
@@ -175,10 +175,6 @@ DEMO_LIST = [
|
|
175 |
"title": "Calculator",
|
176 |
"description": "Build a basic calculator with addition, subtraction, multiplication, and division"
|
177 |
},
|
178 |
-
{
|
179 |
-
"title": "Weather Dashboard",
|
180 |
-
"description": "Create a weather dashboard that displays current weather information"
|
181 |
-
},
|
182 |
{
|
183 |
"title": "Chat Interface",
|
184 |
"description": "Build a chat interface with message history and user input"
|
@@ -1130,7 +1126,7 @@ with gr.Blocks(
|
|
1130 |
visible=True # Always visible
|
1131 |
)
|
1132 |
website_url_input = gr.Textbox(
|
1133 |
-
label="
|
1134 |
placeholder="https://example.com",
|
1135 |
lines=1,
|
1136 |
visible=True # Always visible
|
@@ -1158,15 +1154,7 @@ with gr.Blocks(
|
|
1158 |
label="Model",
|
1159 |
visible=True # Always visible
|
1160 |
)
|
1161 |
-
provider_choices
|
1162 |
-
"auto", "black-forest-labs", "cerebras", "cohere", "fal-ai", "featherless-ai", "fireworks-ai", "groq", "hf-inference", "hyperbolic", "nebius", "novita", "nscale", "openai", "replicate", "sambanova", "together"
|
1163 |
-
]
|
1164 |
-
provider_dropdown = gr.Dropdown(
|
1165 |
-
choices=provider_choices,
|
1166 |
-
value="auto",
|
1167 |
-
label="Provider",
|
1168 |
-
visible=True
|
1169 |
-
)
|
1170 |
provider_state = gr.State("auto")
|
1171 |
gr.Markdown("**Quick start**", visible=True)
|
1172 |
with gr.Column(visible=True) as quick_examples_col:
|
@@ -1182,58 +1170,20 @@ with gr.Blocks(
|
|
1182 |
)
|
1183 |
if not tavily_client:
|
1184 |
gr.Markdown("⚠️ Web search unavailable", visible=True)
|
1185 |
-
|
1186 |
-
gr.Markdown("✅ Web search available", visible=True)
|
1187 |
-
model_display = gr.Markdown(f"**Model:** {AVAILABLE_MODELS[0]['name']}", visible=True) # Moonshot Kimi-K2
|
1188 |
def on_model_change(model_name):
|
1189 |
for m in AVAILABLE_MODELS:
|
1190 |
if m['name'] == model_name:
|
1191 |
-
return m,
|
1192 |
-
return AVAILABLE_MODELS[0],
|
1193 |
def save_prompt(input):
|
1194 |
return {setting: {"system": input}}
|
1195 |
model_dropdown.change(
|
1196 |
-
on_model_change,
|
1197 |
inputs=model_dropdown,
|
1198 |
-
outputs=[current_model,
|
1199 |
)
|
1200 |
-
|
1201 |
-
systemPromptInput = gr.Textbox(
|
1202 |
-
value=HTML_SYSTEM_PROMPT,
|
1203 |
-
label="System prompt",
|
1204 |
-
lines=5
|
1205 |
-
)
|
1206 |
-
save_prompt_btn = gr.Button("Save", variant="primary", size="sm")
|
1207 |
-
save_prompt_btn.click(save_prompt, inputs=systemPromptInput, outputs=setting)
|
1208 |
-
|
1209 |
-
# Remove login state and timer logic
|
1210 |
-
# login_state = gr.State(False)
|
1211 |
-
# timer = gr.Timer(1, active=True)
|
1212 |
-
# def check_login(label, last_state):
|
1213 |
-
# logged_in = label.startswith("Logout (")
|
1214 |
-
# # Only update if state changes
|
1215 |
-
# if last_state == logged_in:
|
1216 |
-
# return [gr.skip()] * 13 # skip updating all outputs
|
1217 |
-
# return (
|
1218 |
-
# logged_in, # login_state
|
1219 |
-
# gr.update(visible=not logged_in), # login_required_msg
|
1220 |
-
# gr.update(visible=logged_in), # input
|
1221 |
-
# gr.update(visible=logged_in), # website_url_input
|
1222 |
-
# gr.update(visible=logged_in), # file_input
|
1223 |
-
# gr.update(visible=logged_in), # btn
|
1224 |
-
# gr.update(visible=logged_in), # clear_btn
|
1225 |
-
# gr.update(visible=logged_in), # search_toggle
|
1226 |
-
# gr.update(visible=logged_in), # model_dropdown
|
1227 |
-
# gr.update(visible=logged_in), # quick_examples_col
|
1228 |
-
# gr.update(visible=logged_in), # advanced_accordion
|
1229 |
-
# logged_in, # update last_login_state
|
1230 |
-
# gr.update(visible=logged_in), # language_dropdown
|
1231 |
-
# )
|
1232 |
-
# timer.tick(
|
1233 |
-
# fn=check_login,
|
1234 |
-
# inputs=[login_button, last_login_state],
|
1235 |
-
# outputs=[login_state, login_required_msg, input, website_url_input, file_input, btn, clear_btn, search_toggle, model_dropdown, quick_examples_col, advanced_accordion, last_login_state, language_dropdown]
|
1236 |
-
# )
|
1237 |
|
1238 |
with gr.Column():
|
1239 |
with gr.Tabs():
|
@@ -1271,14 +1221,5 @@ with gr.Blocks(
|
|
1271 |
language_dropdown.change(preview_logic, inputs=[code_output, language_dropdown], outputs=sandbox)
|
1272 |
clear_btn.click(clear_history, outputs=[history, history_output, file_input, website_url_input])
|
1273 |
|
1274 |
-
def on_provider_change(provider):
|
1275 |
-
return provider
|
1276 |
-
|
1277 |
-
provider_dropdown.change(
|
1278 |
-
on_provider_change,
|
1279 |
-
inputs=provider_dropdown,
|
1280 |
-
outputs=provider_state
|
1281 |
-
)
|
1282 |
-
|
1283 |
if __name__ == "__main__":
|
1284 |
demo.queue(api_open=False, default_concurrency_limit=20).launch(ssr_mode=True, mcp_server=False, show_api=False)
|
|
|
175 |
"title": "Calculator",
|
176 |
"description": "Build a basic calculator with addition, subtraction, multiplication, and division"
|
177 |
},
|
|
|
|
|
|
|
|
|
178 |
{
|
179 |
"title": "Chat Interface",
|
180 |
"description": "Build a chat interface with message history and user input"
|
|
|
1126 |
visible=True # Always visible
|
1127 |
)
|
1128 |
website_url_input = gr.Textbox(
|
1129 |
+
label="website for redesign",
|
1130 |
placeholder="https://example.com",
|
1131 |
lines=1,
|
1132 |
visible=True # Always visible
|
|
|
1154 |
label="Model",
|
1155 |
visible=True # Always visible
|
1156 |
)
|
1157 |
+
# Remove provider_choices and provider_dropdown, set provider_state to 'auto' only
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1158 |
provider_state = gr.State("auto")
|
1159 |
gr.Markdown("**Quick start**", visible=True)
|
1160 |
with gr.Column(visible=True) as quick_examples_col:
|
|
|
1170 |
)
|
1171 |
if not tavily_client:
|
1172 |
gr.Markdown("⚠️ Web search unavailable", visible=True)
|
1173 |
+
# Remove model display and web search available line
|
|
|
|
|
1174 |
def on_model_change(model_name):
|
1175 |
for m in AVAILABLE_MODELS:
|
1176 |
if m['name'] == model_name:
|
1177 |
+
return m, update_image_input_visibility(m)
|
1178 |
+
return AVAILABLE_MODELS[0], update_image_input_visibility(AVAILABLE_MODELS[0]) # Moonshot Kimi-K2 fallback
|
1179 |
def save_prompt(input):
|
1180 |
return {setting: {"system": input}}
|
1181 |
model_dropdown.change(
|
1182 |
+
lambda model_name: on_model_change(model_name),
|
1183 |
inputs=model_dropdown,
|
1184 |
+
outputs=[current_model, image_input]
|
1185 |
)
|
1186 |
+
# Remove the Advanced accordion and system prompt editing UI
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1187 |
|
1188 |
with gr.Column():
|
1189 |
with gr.Tabs():
|
|
|
1221 |
language_dropdown.change(preview_logic, inputs=[code_output, language_dropdown], outputs=sandbox)
|
1222 |
clear_btn.click(clear_history, outputs=[history, history_output, file_input, website_url_input])
|
1223 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1224 |
if __name__ == "__main__":
|
1225 |
demo.queue(api_open=False, default_concurrency_limit=20).launch(ssr_mode=True, mcp_server=False, show_api=False)
|