Spaces:
Sleeping
Sleeping
Fix: Handle MiniMax reasoning field in response
Browse files- proxy_cerebras.py +10 -1
proxy_cerebras.py
CHANGED
|
@@ -212,6 +212,11 @@ def ollama_to_anthropic(ollama_response: dict, original_model: str) -> dict:
|
|
| 212 |
|
| 213 |
done_reason = ollama_response.get("done_reason", "stop")
|
| 214 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 215 |
return {
|
| 216 |
"id": f"msg_{uuid.uuid4().hex[:10]}",
|
| 217 |
"type": "message",
|
|
@@ -219,7 +224,7 @@ def ollama_to_anthropic(ollama_response: dict, original_model: str) -> dict:
|
|
| 219 |
"content": [
|
| 220 |
{
|
| 221 |
"type": "text",
|
| 222 |
-
"text":
|
| 223 |
}
|
| 224 |
],
|
| 225 |
"model": original_model,
|
|
@@ -280,6 +285,10 @@ async def stream_anthropic(ollama_stream, original_model: str):
|
|
| 280 |
message = data.get("message", {})
|
| 281 |
content = message.get("content", "")
|
| 282 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 283 |
if content:
|
| 284 |
# Send text_delta
|
| 285 |
content_block_delta_data = {
|
|
|
|
| 212 |
|
| 213 |
done_reason = ollama_response.get("done_reason", "stop")
|
| 214 |
|
| 215 |
+
# Handle MiniMax quirk: content might be in 'reasoning' field
|
| 216 |
+
text_content = message.get("content", "")
|
| 217 |
+
if not text_content and message.get("reasoning"):
|
| 218 |
+
text_content = message.get("reasoning", "")
|
| 219 |
+
|
| 220 |
return {
|
| 221 |
"id": f"msg_{uuid.uuid4().hex[:10]}",
|
| 222 |
"type": "message",
|
|
|
|
| 224 |
"content": [
|
| 225 |
{
|
| 226 |
"type": "text",
|
| 227 |
+
"text": text_content
|
| 228 |
}
|
| 229 |
],
|
| 230 |
"model": original_model,
|
|
|
|
| 285 |
message = data.get("message", {})
|
| 286 |
content = message.get("content", "")
|
| 287 |
|
| 288 |
+
# Handle MiniMax quirk: content might be in 'reasoning' field
|
| 289 |
+
if not content and message.get("reasoning"):
|
| 290 |
+
content = message.get("reasoning", "")
|
| 291 |
+
|
| 292 |
if content:
|
| 293 |
# Send text_delta
|
| 294 |
content_block_delta_data = {
|