mbxai 1.0.8__tar.gz → 1.0.10__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.8 → mbxai-1.0.10}/PKG-INFO +1 -1
- {mbxai-1.0.8 → mbxai-1.0.10}/pyproject.toml +1 -1
- {mbxai-1.0.8 → mbxai-1.0.10}/setup.py +1 -1
- {mbxai-1.0.8 → mbxai-1.0.10}/src/mbxai/__init__.py +1 -1
- {mbxai-1.0.8 → mbxai-1.0.10}/src/mbxai/mcp/server.py +1 -1
- {mbxai-1.0.8 → mbxai-1.0.10}/src/mbxai/openrouter/client.py +17 -15
- {mbxai-1.0.8 → mbxai-1.0.10}/.gitignore +0 -0
- {mbxai-1.0.8 → mbxai-1.0.10}/LICENSE +0 -0
- {mbxai-1.0.8 → mbxai-1.0.10}/README.md +0 -0
- {mbxai-1.0.8 → mbxai-1.0.10}/src/mbxai/core.py +0 -0
- {mbxai-1.0.8 → mbxai-1.0.10}/src/mbxai/examples/mcp/mcp_client_example.py +0 -0
- {mbxai-1.0.8 → mbxai-1.0.10}/src/mbxai/examples/mcp/mcp_server_example.py +0 -0
- {mbxai-1.0.8 → mbxai-1.0.10}/src/mbxai/examples/openrouter_example.py +0 -0
- {mbxai-1.0.8 → mbxai-1.0.10}/src/mbxai/examples/parse_example.py +0 -0
- {mbxai-1.0.8 → mbxai-1.0.10}/src/mbxai/examples/parse_tool_example.py +0 -0
- {mbxai-1.0.8 → mbxai-1.0.10}/src/mbxai/examples/tool_client_example.py +0 -0
- {mbxai-1.0.8 → mbxai-1.0.10}/src/mbxai/mcp/__init__.py +0 -0
- {mbxai-1.0.8 → mbxai-1.0.10}/src/mbxai/mcp/client.py +0 -0
- {mbxai-1.0.8 → mbxai-1.0.10}/src/mbxai/mcp/example.py +0 -0
- {mbxai-1.0.8 → mbxai-1.0.10}/src/mbxai/openrouter/__init__.py +0 -0
- {mbxai-1.0.8 → mbxai-1.0.10}/src/mbxai/openrouter/config.py +0 -0
- {mbxai-1.0.8 → mbxai-1.0.10}/src/mbxai/openrouter/models.py +0 -0
- {mbxai-1.0.8 → mbxai-1.0.10}/src/mbxai/tools/__init__.py +0 -0
- {mbxai-1.0.8 → mbxai-1.0.10}/src/mbxai/tools/client.py +0 -0
- {mbxai-1.0.8 → mbxai-1.0.10}/src/mbxai/tools/example.py +0 -0
- {mbxai-1.0.8 → mbxai-1.0.10}/src/mbxai/tools/types.py +0 -0
@@ -3,7 +3,7 @@ OpenRouter client implementation.
|
|
3
3
|
"""
|
4
4
|
|
5
5
|
from typing import Any, Optional, Union
|
6
|
-
from openai import OpenAI, OpenAIError, RateLimitError, APITimeoutError, APIConnectionError,
|
6
|
+
from openai import OpenAI, OpenAIError, RateLimitError, APITimeoutError, APIConnectionError, BadRequestError, AuthenticationError
|
7
7
|
from .models import OpenRouterModel, OpenRouterModelRegistry
|
8
8
|
from .config import OpenRouterConfig
|
9
9
|
import logging
|
@@ -254,6 +254,17 @@ class OpenRouterClient:
|
|
254
254
|
**kwargs: Any,
|
255
255
|
) -> Any:
|
256
256
|
"""Get a chat completion from OpenRouter."""
|
257
|
+
|
258
|
+
request = {
|
259
|
+
"model": model or self.model,
|
260
|
+
"messages": messages,
|
261
|
+
"response_format": response_format,
|
262
|
+
**kwargs,
|
263
|
+
}
|
264
|
+
|
265
|
+
# Log the full request for debugging
|
266
|
+
logger.debug(f"Full request: {request}")
|
267
|
+
|
257
268
|
try:
|
258
269
|
# Log the request details
|
259
270
|
logger.info(f"Sending parse request to OpenRouter with model: {model or self.model}")
|
@@ -264,16 +275,6 @@ class OpenRouterClient:
|
|
264
275
|
total_size = sum(len(str(msg)) for msg in messages)
|
265
276
|
logger.info(f"Total message size: {total_size} bytes")
|
266
277
|
|
267
|
-
request = {
|
268
|
-
"model": model or self.model,
|
269
|
-
"messages": messages,
|
270
|
-
"response_format": response_format,
|
271
|
-
**kwargs,
|
272
|
-
}
|
273
|
-
|
274
|
-
# Log the full request for debugging
|
275
|
-
logger.debug(f"Full request: {request}")
|
276
|
-
|
277
278
|
try:
|
278
279
|
response = self._client.beta.chat.completions.parse(**request)
|
279
280
|
except RateLimitError as e:
|
@@ -288,9 +289,9 @@ class OpenRouterClient:
|
|
288
289
|
except AuthenticationError as e:
|
289
290
|
logger.error(f"Authentication error: {str(e)}")
|
290
291
|
raise OpenRouterAPIError(f"Authentication error: {str(e)}")
|
291
|
-
except
|
292
|
-
logger.error(f"
|
293
|
-
raise OpenRouterAPIError(f"
|
292
|
+
except BadRequestError as e:
|
293
|
+
logger.error(f"Bad request: {str(e)}")
|
294
|
+
raise OpenRouterAPIError(f"Bad request: {str(e)}")
|
294
295
|
except OpenAIError as e:
|
295
296
|
logger.error(f"OpenAI error: {str(e)}")
|
296
297
|
raise OpenRouterAPIError(f"OpenAI error: {str(e)}")
|
@@ -353,7 +354,8 @@ class OpenRouterClient:
|
|
353
354
|
|
354
355
|
except Exception as e:
|
355
356
|
stack_trace = traceback.format_exc()
|
356
|
-
logger.
|
357
|
+
logger.error(f"Raising error: {e}")
|
358
|
+
logger.error(f"Full request from ERROR: {request}")
|
357
359
|
logger.error(f"Error in parse completion: {str(e)}")
|
358
360
|
logger.error(f"Stack trace:\n{stack_trace}")
|
359
361
|
logger.error(f"Request details: model={model or self.model}, response_format={response_format}, kwargs={kwargs}")
|
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
|