mbxai 1.0.2__tar.gz → 1.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mbxai-1.0.2 → mbxai-1.0.3}/PKG-INFO +1 -1
- {mbxai-1.0.2 → mbxai-1.0.3}/pyproject.toml +1 -1
- {mbxai-1.0.2 → mbxai-1.0.3}/setup.py +1 -1
- {mbxai-1.0.2 → mbxai-1.0.3}/src/mbxai/__init__.py +1 -1
- {mbxai-1.0.2 → mbxai-1.0.3}/src/mbxai/mcp/server.py +1 -1
- {mbxai-1.0.2 → mbxai-1.0.3}/src/mbxai/openrouter/client.py +29 -1
- {mbxai-1.0.2 → mbxai-1.0.3}/.gitignore +0 -0
- {mbxai-1.0.2 → mbxai-1.0.3}/LICENSE +0 -0
- {mbxai-1.0.2 → mbxai-1.0.3}/README.md +0 -0
- {mbxai-1.0.2 → mbxai-1.0.3}/src/mbxai/core.py +0 -0
- {mbxai-1.0.2 → mbxai-1.0.3}/src/mbxai/examples/mcp/mcp_client_example.py +0 -0
- {mbxai-1.0.2 → mbxai-1.0.3}/src/mbxai/examples/mcp/mcp_server_example.py +0 -0
- {mbxai-1.0.2 → mbxai-1.0.3}/src/mbxai/examples/openrouter_example.py +0 -0
- {mbxai-1.0.2 → mbxai-1.0.3}/src/mbxai/examples/parse_example.py +0 -0
- {mbxai-1.0.2 → mbxai-1.0.3}/src/mbxai/examples/parse_tool_example.py +0 -0
- {mbxai-1.0.2 → mbxai-1.0.3}/src/mbxai/examples/tool_client_example.py +0 -0
- {mbxai-1.0.2 → mbxai-1.0.3}/src/mbxai/mcp/__init__.py +0 -0
- {mbxai-1.0.2 → mbxai-1.0.3}/src/mbxai/mcp/client.py +0 -0
- {mbxai-1.0.2 → mbxai-1.0.3}/src/mbxai/mcp/example.py +0 -0
- {mbxai-1.0.2 → mbxai-1.0.3}/src/mbxai/openrouter/__init__.py +0 -0
- {mbxai-1.0.2 → mbxai-1.0.3}/src/mbxai/openrouter/config.py +0 -0
- {mbxai-1.0.2 → mbxai-1.0.3}/src/mbxai/openrouter/models.py +0 -0
- {mbxai-1.0.2 → mbxai-1.0.3}/src/mbxai/tools/__init__.py +0 -0
- {mbxai-1.0.2 → mbxai-1.0.3}/src/mbxai/tools/client.py +0 -0
- {mbxai-1.0.2 → mbxai-1.0.3}/src/mbxai/tools/example.py +0 -0
- {mbxai-1.0.2 → mbxai-1.0.3}/src/mbxai/tools/types.py +0 -0
@@ -275,10 +275,38 @@ class OpenRouterClient:
|
|
275
275
|
logger.info(f"Response type: {type(response)}")
|
276
276
|
logger.info(f"Response attributes: {dir(response)}")
|
277
277
|
|
278
|
+
# Validate response structure
|
278
279
|
if not hasattr(response, 'choices'):
|
279
280
|
logger.error(f"Response missing 'choices' attribute. Available attributes: {dir(response)}")
|
280
281
|
raise OpenRouterAPIError("Invalid response format: missing 'choices' attribute")
|
281
|
-
|
282
|
+
|
283
|
+
if not response.choices:
|
284
|
+
logger.error("Response has empty choices list")
|
285
|
+
raise OpenRouterAPIError("Invalid response format: empty choices list")
|
286
|
+
|
287
|
+
if not hasattr(response.choices[0], 'message'):
|
288
|
+
logger.error(f"First choice missing 'message' attribute. Available attributes: {dir(response.choices[0])}")
|
289
|
+
raise OpenRouterAPIError("Invalid response format: missing 'message' attribute in first choice")
|
290
|
+
|
291
|
+
# Check if the message has a parsed attribute or content
|
292
|
+
if not hasattr(response.choices[0].message, 'parsed') and not hasattr(response.choices[0].message, 'content'):
|
293
|
+
logger.error(f"Message missing both 'parsed' and 'content' attributes. Available attributes: {dir(response.choices[0].message)}")
|
294
|
+
raise OpenRouterAPIError("Invalid response format: message must have either 'parsed' or 'content' attribute")
|
295
|
+
|
296
|
+
# If there's no parsed attribute but there is content, try to parse it
|
297
|
+
if not hasattr(response.choices[0].message, 'parsed') and hasattr(response.choices[0].message, 'content'):
|
298
|
+
try:
|
299
|
+
import json
|
300
|
+
content = response.choices[0].message.content
|
301
|
+
if isinstance(content, str):
|
302
|
+
parsed = json.loads(content)
|
303
|
+
response.choices[0].message.parsed = parsed
|
304
|
+
else:
|
305
|
+
response.choices[0].message.parsed = content
|
306
|
+
except Exception as e:
|
307
|
+
logger.error(f"Failed to parse message content: {str(e)}")
|
308
|
+
raise OpenRouterAPIError(f"Failed to parse message content: {str(e)}")
|
309
|
+
|
282
310
|
logger.info(f"Received response from OpenRouter: {len(response.choices)} choices")
|
283
311
|
|
284
312
|
return response
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|