Update app.py
Browse files
app.py
CHANGED
|
@@ -72,10 +72,6 @@ OPENROUTER_MODELS = [
|
|
| 72 |
|
| 73 |
# --- Reactive State Event Handlers ---
|
| 74 |
def change_provider_options(provider_choice):
|
| 75 |
-
"""
|
| 76 |
-
Explicitly utilizes the Gradio dictionary update method to override
|
| 77 |
-
the active parameters in the client's rendered browser viewport.
|
| 78 |
-
"""
|
| 79 |
if provider_choice == "Groq":
|
| 80 |
return gr.Dropdown(choices=GROQ_MODELS, value=GROQ_MODELS[0], interactive=True)
|
| 81 |
elif provider_choice == "OpenRouter":
|
|
@@ -251,25 +247,29 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 251 |
chat_input = gr.Textbox(placeholder="Say hello, or submit task details to log...", label="Your Message")
|
| 252 |
send_btn = gr.Button("Submit Message", variant="primary")
|
| 253 |
|
| 254 |
-
# Decoupled transaction bindings
|
| 255 |
send_btn.click(
|
| 256 |
fn=append_user_message,
|
| 257 |
inputs=[chatbot_viewport, chat_input],
|
| 258 |
-
outputs=[chatbot_viewport, chat_input]
|
|
|
|
| 259 |
).then(
|
| 260 |
fn=generate_agent_response,
|
| 261 |
inputs=[chatbot_viewport, provider_select, token_input, model_select],
|
| 262 |
-
outputs=[chatbot_viewport]
|
|
|
|
| 263 |
)
|
| 264 |
|
| 265 |
chat_input.submit(
|
| 266 |
fn=append_user_message,
|
| 267 |
inputs=[chatbot_viewport, chat_input],
|
| 268 |
-
outputs=[chatbot_viewport, chat_input]
|
|
|
|
| 269 |
).then(
|
| 270 |
fn=generate_agent_response,
|
| 271 |
inputs=[chatbot_viewport, provider_select, token_input, model_select],
|
| 272 |
-
outputs=[chatbot_viewport]
|
|
|
|
| 273 |
)
|
| 274 |
|
| 275 |
# Tab 2: Natural-Language-to-SQL Inquisitor Desk Node
|
|
@@ -284,20 +284,23 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 284 |
query_btn.click(
|
| 285 |
fn=execute_ai_query,
|
| 286 |
inputs=[provider_select, token_input, model_select, query_input],
|
| 287 |
-
outputs=[output_data_table, sql_status_display]
|
|
|
|
| 288 |
)
|
| 289 |
|
| 290 |
-
# ---
|
| 291 |
provider_select.change(
|
| 292 |
fn=change_provider_options,
|
| 293 |
inputs=[provider_select],
|
| 294 |
-
outputs=[model_select]
|
|
|
|
| 295 |
)
|
| 296 |
|
| 297 |
clear_session_btn.click(
|
| 298 |
fn=clear_chatbot_history,
|
| 299 |
inputs=[],
|
| 300 |
-
outputs=[chatbot_viewport, chat_input]
|
|
|
|
| 301 |
)
|
| 302 |
|
| 303 |
if __name__ == "__main__":
|
|
|
|
| 72 |
|
| 73 |
# --- Reactive State Event Handlers ---
|
| 74 |
def change_provider_options(provider_choice):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
if provider_choice == "Groq":
|
| 76 |
return gr.Dropdown(choices=GROQ_MODELS, value=GROQ_MODELS[0], interactive=True)
|
| 77 |
elif provider_choice == "OpenRouter":
|
|
|
|
| 247 |
chat_input = gr.Textbox(placeholder="Say hello, or submit task details to log...", label="Your Message")
|
| 248 |
send_btn = gr.Button("Submit Message", variant="primary")
|
| 249 |
|
| 250 |
+
# Decoupled transaction bindings with explicit api_name parameters disabled
|
| 251 |
send_btn.click(
|
| 252 |
fn=append_user_message,
|
| 253 |
inputs=[chatbot_viewport, chat_input],
|
| 254 |
+
outputs=[chatbot_viewport, chat_input],
|
| 255 |
+
api_name=False
|
| 256 |
).then(
|
| 257 |
fn=generate_agent_response,
|
| 258 |
inputs=[chatbot_viewport, provider_select, token_input, model_select],
|
| 259 |
+
outputs=[chatbot_viewport],
|
| 260 |
+
api_name=False
|
| 261 |
)
|
| 262 |
|
| 263 |
chat_input.submit(
|
| 264 |
fn=append_user_message,
|
| 265 |
inputs=[chatbot_viewport, chat_input],
|
| 266 |
+
outputs=[chatbot_viewport, chat_input],
|
| 267 |
+
api_name=False
|
| 268 |
).then(
|
| 269 |
fn=generate_agent_response,
|
| 270 |
inputs=[chatbot_viewport, provider_select, token_input, model_select],
|
| 271 |
+
outputs=[chatbot_viewport],
|
| 272 |
+
api_name=False
|
| 273 |
)
|
| 274 |
|
| 275 |
# Tab 2: Natural-Language-to-SQL Inquisitor Desk Node
|
|
|
|
| 284 |
query_btn.click(
|
| 285 |
fn=execute_ai_query,
|
| 286 |
inputs=[provider_select, token_input, model_select, query_input],
|
| 287 |
+
outputs=[output_data_table, sql_status_display],
|
| 288 |
+
api_name=False
|
| 289 |
)
|
| 290 |
|
| 291 |
+
# --- REACTIVE STATE BINDINGS (Bypassing API Compilation Loops) ---
|
| 292 |
provider_select.change(
|
| 293 |
fn=change_provider_options,
|
| 294 |
inputs=[provider_select],
|
| 295 |
+
outputs=[model_select],
|
| 296 |
+
api_name=False
|
| 297 |
)
|
| 298 |
|
| 299 |
clear_session_btn.click(
|
| 300 |
fn=clear_chatbot_history,
|
| 301 |
inputs=[],
|
| 302 |
+
outputs=[chatbot_viewport, chat_input],
|
| 303 |
+
api_name=False
|
| 304 |
)
|
| 305 |
|
| 306 |
if __name__ == "__main__":
|