Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -166,6 +166,7 @@ def add_bot_message(history: list[dict], bot_message: str) -> list[dict]:
|
|
166 |
history.append({"role": "assistant", "content": bot_message})
|
167 |
return history
|
168 |
|
|
|
169 |
def ai_workflow_chat(
|
170 |
message: str,
|
171 |
history: list[dict],
|
@@ -183,6 +184,8 @@ def ai_workflow_chat(
|
|
183 |
app_description_state: str | None,
|
184 |
repo_name_state: str | None,
|
185 |
generated_code_state: str | None,
|
|
|
|
|
186 |
) -> tuple[
|
187 |
list[dict],
|
188 |
str | None,
|
@@ -638,13 +641,18 @@ with gr.Blocks(title="AI-Powered HF Space App Builder") as ai_builder_tab:
|
|
638 |
send_btn = gr.Button("Send", interactive=False)
|
639 |
|
640 |
# Logic to enable send button only when logged in and API key is set
|
641 |
-
|
642 |
-
|
643 |
-
|
|
|
|
|
|
|
|
|
|
|
644 |
return gr.update(interactive=is_logged_in and is_gemini_ready)
|
645 |
|
646 |
# Bind update_send_button_state to the *change* of the relevant state variables
|
647 |
-
# This ensures it's called with the correct 4 state values
|
648 |
hf_profile.change(
|
649 |
update_send_button_state,
|
650 |
inputs=[hf_profile, hf_token, gemini_key, gemini_model],
|
|
|
166 |
history.append({"role": "assistant", "content": bot_message})
|
167 |
return history
|
168 |
|
169 |
+
# Modified function signature to accept *args and **kwargs
|
170 |
def ai_workflow_chat(
|
171 |
message: str,
|
172 |
history: list[dict],
|
|
|
184 |
app_description_state: str | None,
|
185 |
repo_name_state: str | None,
|
186 |
generated_code_state: str | None,
|
187 |
+
*args, # Catch extra positional arguments
|
188 |
+
**kwargs # Catch extra keyword arguments
|
189 |
) -> tuple[
|
190 |
list[dict],
|
191 |
str | None,
|
|
|
641 |
send_btn = gr.Button("Send", interactive=False)
|
642 |
|
643 |
# Logic to enable send button only when logged in and API key is set
|
644 |
+
# Modified function signature to accept *args and **kwargs
|
645 |
+
def update_send_button_state(profile: gr.OAuthProfile | None, token: gr.OAuthToken | None, key: str | None, model: str | None, *args, **kwargs):
|
646 |
+
"""
|
647 |
+
Gradio sometimes passes extra positional/keyword args (old_value, event, etc.),
|
648 |
+
so we absorb them with *args/**kwargs.
|
649 |
+
"""
|
650 |
+
is_logged_in = profile is not None and token is not None
|
651 |
+
is_gemini_ready = key is not None and model is not None
|
652 |
return gr.update(interactive=is_logged_in and is_gemini_ready)
|
653 |
|
654 |
# Bind update_send_button_state to the *change* of the relevant state variables
|
655 |
+
# This ensures it's called with the correct 4 state values plus any extras
|
656 |
hf_profile.change(
|
657 |
update_send_button_state,
|
658 |
inputs=[hf_profile, hf_token, gemini_key, gemini_model],
|