Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,7 +15,7 @@ import gradio as gr
|
|
| 15 |
import spaces
|
| 16 |
import wikipedia
|
| 17 |
|
| 18 |
-
from
|
| 19 |
|
| 20 |
|
| 21 |
# =========================================================
|
|
@@ -144,9 +144,7 @@ def generate_groq_response(prompt: str) -> str:
|
|
| 144 |
],
|
| 145 |
"temperature": 0.0,
|
| 146 |
"max_tokens": 2048
|
| 147 |
-
# Removed "tool_choice": "none" to prevent Groq API validation rejections
|
| 148 |
}
|
| 149 |
-
|
| 150 |
|
| 151 |
for attempt in range(MAX_RETRIES + 1):
|
| 152 |
try:
|
|
@@ -254,7 +252,6 @@ def generate_groq_response(prompt: str) -> str:
|
|
| 254 |
|
| 255 |
finish_reason = choice.get("finish_reason", "unknown")
|
| 256 |
|
| 257 |
-
# Graceful fallback instead of hard-crashing entire evaluation
|
| 258 |
print(
|
| 259 |
f"Warning: Groq returned empty content. "
|
| 260 |
f"Model: {GROQ_MODEL}, Finish reason: {finish_reason}"
|
|
@@ -310,7 +307,6 @@ def generate_answers(prompts: list[str]) -> list[str]:
|
|
| 310 |
f"Original error: {error}"
|
| 311 |
) from error
|
| 312 |
|
| 313 |
-
# Avoid unnecessary waiting after the final question
|
| 314 |
if index < len(prompts):
|
| 315 |
time.sleep(PAUSE_SECONDS)
|
| 316 |
|
|
|
|
| 15 |
import spaces
|
| 16 |
import wikipedia
|
| 17 |
|
| 18 |
+
from duckduckgo_search import DDGS
|
| 19 |
|
| 20 |
|
| 21 |
# =========================================================
|
|
|
|
| 144 |
],
|
| 145 |
"temperature": 0.0,
|
| 146 |
"max_tokens": 2048
|
|
|
|
| 147 |
}
|
|
|
|
| 148 |
|
| 149 |
for attempt in range(MAX_RETRIES + 1):
|
| 150 |
try:
|
|
|
|
| 252 |
|
| 253 |
finish_reason = choice.get("finish_reason", "unknown")
|
| 254 |
|
|
|
|
| 255 |
print(
|
| 256 |
f"Warning: Groq returned empty content. "
|
| 257 |
f"Model: {GROQ_MODEL}, Finish reason: {finish_reason}"
|
|
|
|
| 307 |
f"Original error: {error}"
|
| 308 |
) from error
|
| 309 |
|
|
|
|
| 310 |
if index < len(prompts):
|
| 311 |
time.sleep(PAUSE_SECONDS)
|
| 312 |
|