Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -141,7 +141,7 @@ def classify(req: ExplainRequest):
|
|
| 141 |
{"role": "user", "content": user_message}
|
| 142 |
],
|
| 143 |
"temperature": 0.0,
|
| 144 |
-
"max_tokens":
|
| 145 |
}
|
| 146 |
|
| 147 |
try:
|
|
@@ -160,6 +160,11 @@ def classify(req: ExplainRequest):
|
|
| 160 |
reply = result.get("choices", [{}])[0].get("message", {}).get("content", "").strip()
|
| 161 |
|
| 162 |
if not reply:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
logger.error(f"OpenRouter returned empty response in /classify. Full result: {result}")
|
| 164 |
raise HTTPException(status_code=500, detail="No response from OpenRouter")
|
| 165 |
|
|
|
|
| 141 |
{"role": "user", "content": user_message}
|
| 142 |
],
|
| 143 |
"temperature": 0.0,
|
| 144 |
+
"max_tokens": 2000 # Increased for models with extended reasoning/thinking
|
| 145 |
}
|
| 146 |
|
| 147 |
try:
|
|
|
|
| 160 |
reply = result.get("choices", [{}])[0].get("message", {}).get("content", "").strip()
|
| 161 |
|
| 162 |
if not reply:
|
| 163 |
+
logger.warning(f"Empty content in response. Finish reason: {result.get('choices', [{}])[0].get('finish_reason')}")
|
| 164 |
+
# If content is empty, try to extract from reasoning or log for debugging
|
| 165 |
+
reasoning = result.get("choices", [{}])[0].get("message", {}).get("reasoning", "")
|
| 166 |
+
if reasoning:
|
| 167 |
+
logger.warning(f"Model has reasoning but no content. This may indicate truncation.")
|
| 168 |
logger.error(f"OpenRouter returned empty response in /classify. Full result: {result}")
|
| 169 |
raise HTTPException(status_code=500, detail="No response from OpenRouter")
|
| 170 |
|