Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -559,10 +559,10 @@ def send_to_model_impl(prompt, model_selection, hf_model_choice, hf_custom_model
|
|
| 559 |
if summary.startswith("Error: This model requires authentication") and hf_api_key:
|
| 560 |
# Only try with API key if the model specifically requires it
|
| 561 |
summary = send_to_hf_inference(prompt, model_id, hf_api_key, use_rate_limits)
|
| 562 |
-
|
| 563 |
elif model_selection == "Groq API":
|
| 564 |
if not groq_api_key:
|
| 565 |
-
return "Error: Groq API key required", None
|
| 566 |
summary = send_to_groq(prompt, groq_model_choice, groq_api_key, use_rate_limits)
|
| 567 |
|
| 568 |
elif model_selection == "OpenAI ChatGPT":
|
|
@@ -591,10 +591,10 @@ def send_to_model_impl(prompt, model_selection, hf_model_choice, hf_custom_model
|
|
| 591 |
|
| 592 |
# Validate response
|
| 593 |
if not summary:
|
| 594 |
-
return "Error: No response from model", None
|
| 595 |
|
| 596 |
if not isinstance(summary, str):
|
| 597 |
-
return "Error: Invalid response type from model", None
|
| 598 |
|
| 599 |
# Create download file for valid responses
|
| 600 |
if not summary.startswith("Error"):
|
|
@@ -602,14 +602,15 @@ def send_to_model_impl(prompt, model_selection, hf_model_choice, hf_custom_model
|
|
| 602 |
f.write(summary)
|
| 603 |
return gr.HTML(""), summary, f.name
|
| 604 |
|
| 605 |
-
return gr.HTML(""), summary,
|
| 606 |
|
| 607 |
except Exception as e:
|
| 608 |
error_msg = str(e)
|
| 609 |
if not error_msg:
|
| 610 |
error_msg = "Unknown error occurred"
|
| 611 |
logging.error(f"Error in send_to_model_impl: {error_msg}")
|
| 612 |
-
|
|
|
|
| 613 |
|
| 614 |
def send_to_qwq(prompt: str):
|
| 615 |
"""Send prompt to QwQ API."""
|
|
|
|
| 559 |
if summary.startswith("Error: This model requires authentication") and hf_api_key:
|
| 560 |
# Only try with API key if the model specifically requires it
|
| 561 |
summary = send_to_hf_inference(prompt, model_id, hf_api_key, use_rate_limits)
|
| 562 |
+
|
| 563 |
elif model_selection == "Groq API":
|
| 564 |
if not groq_api_key:
|
| 565 |
+
return gr.HTML(""), "Error: Groq API key required", None
|
| 566 |
summary = send_to_groq(prompt, groq_model_choice, groq_api_key, use_rate_limits)
|
| 567 |
|
| 568 |
elif model_selection == "OpenAI ChatGPT":
|
|
|
|
| 591 |
|
| 592 |
# Validate response
|
| 593 |
if not summary:
|
| 594 |
+
return gr.HTML(""), "Error: No response from model", None
|
| 595 |
|
| 596 |
if not isinstance(summary, str):
|
| 597 |
+
return gr.HTML(""), "Error: Invalid response type from model", None
|
| 598 |
|
| 599 |
# Create download file for valid responses
|
| 600 |
if not summary.startswith("Error"):
|
|
|
|
| 602 |
f.write(summary)
|
| 603 |
return gr.HTML(""), summary, f.name
|
| 604 |
|
| 605 |
+
return gr.HTML(""), summary, None
|
| 606 |
|
| 607 |
except Exception as e:
|
| 608 |
error_msg = str(e)
|
| 609 |
if not error_msg:
|
| 610 |
error_msg = "Unknown error occurred"
|
| 611 |
logging.error(f"Error in send_to_model_impl: {error_msg}")
|
| 612 |
+
# FIX: Return all three values even in error case
|
| 613 |
+
return gr.HTML(""), f"Error: {error_msg}", None
|
| 614 |
|
| 615 |
def send_to_qwq(prompt: str):
|
| 616 |
"""Send prompt to QwQ API."""
|