mbxai 0.5.22__py3-none-any.whl → 0.5.23__py3-none-any.whl

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/__init__.py CHANGED
@@ -2,4 +2,4 @@
2
2
  MBX AI package.
3
3
  """
4
4
 
5
- __version__ = "0.5.22"
5
+ __version__ = "0.5.23"
mbxai/mcp/server.py CHANGED
@@ -31,7 +31,7 @@ class MCPServer:
31
31
  self.app = FastAPI(
32
32
  title=self.name,
33
33
  description=self.description,
34
- version="0.5.22",
34
+ version="0.5.23",
35
35
  )
36
36
 
37
37
  # Initialize MCP server
@@ -115,74 +115,41 @@ class OpenRouterClient:
115
115
  self,
116
116
  messages: list[dict[str, Any]],
117
117
  *,
118
- model: Optional[Union[str, OpenRouterModel]] = None,
118
+ model: str | None = None,
119
119
  stream: bool = False,
120
120
  **kwargs: Any,
121
121
  ) -> Any:
122
- """Create a chat completion.
123
-
124
- Args:
125
- messages: list of messages
126
- model: Optional model override
127
- stream: Whether to stream the response
128
- **kwargs: Additional parameters
129
-
130
- Returns:
131
- Completion response
132
-
133
- Raises:
134
- OpenRouterConnectionError: For connection issues
135
- OpenRouterAPIError: For API errors
136
- OpenRouterError: For other errors
137
- """
122
+ """Get a chat completion from OpenRouter."""
138
123
  try:
139
- # Remove any incompatible parameters
140
- kwargs.pop("parse", None) # Remove parse parameter if present
141
-
142
- logger.debug(f"Making chat completion request with model {model or self.model}")
143
- logger.debug(f"Request messages: {messages}")
144
- logger.debug(f"Request kwargs: {kwargs}")
124
+ # Log the request details
125
+ logger.info(f"Sending chat completion request to OpenRouter with model: {model}")
126
+ logger.info(f"Message count: {len(messages)}")
145
127
 
146
128
  response = self._client.chat.completions.create(
147
- model=str(model or self.model),
148
129
  messages=messages,
130
+ model=model or self.model,
149
131
  stream=stream,
150
132
  **kwargs,
151
133
  )
152
134
 
153
- # Log response structure for debugging
154
- logger.debug(f"Response type: {type(response)}")
155
- logger.debug(f"Response attributes: {dir(response)}")
156
- logger.debug(f"Raw response: {response}")
157
-
158
- # Handle streaming response differently
159
- if stream:
160
- return response
161
-
162
- # Validate response structure
163
- if response is None:
164
- logger.error("Received None response from API")
165
- raise OpenRouterError("Received None response from API")
166
-
167
- if not hasattr(response, 'choices'):
168
- logger.error(f"Invalid response: missing choices attribute. Response: {response}")
169
- raise OpenRouterError("Invalid response: missing choices attribute")
170
-
171
- if not response.choices:
172
- logger.error(f"Invalid response: empty choices list. Response: {response}")
173
- raise OpenRouterError("Invalid response: empty choices list")
174
-
175
- if not hasattr(response.choices[0], 'message'):
176
- logger.error(f"Invalid response: missing message in first choice. Response: {response}")
177
- raise OpenRouterError("Invalid response: missing message in first choice")
135
+ # Log response details
136
+ logger.info("Received response from OpenRouter")
137
+ if hasattr(response, 'choices') and response.choices:
138
+ logger.info(f"Response has {len(response.choices)} choices")
139
+ if hasattr(response.choices[0], 'message'):
140
+ logger.info(f"First choice has message with content length: {len(response.choices[0].message.content) if response.choices[0].message.content else 0}")
178
141
 
179
- logger.debug(f"Response message: {response.choices[0].message}")
180
142
  return response
181
143
 
182
144
  except Exception as e:
183
145
  logger.error(f"Error in chat completion: {str(e)}")
184
- if isinstance(e, OpenRouterError):
185
- raise
146
+ if hasattr(e, 'response') and e.response is not None:
147
+ logger.error(f"Response status: {e.response.status_code}")
148
+ logger.error(f"Response headers: {e.response.headers}")
149
+ try:
150
+ logger.error(f"Response content: {e.response.text[:1000]}...")
151
+ except:
152
+ logger.error("Could not read response content")
186
153
  self._handle_api_error("chat completion", e)
187
154
 
188
155
  def chat_completion_parse(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mbxai
3
- Version: 0.5.22
3
+ Version: 0.5.23
4
4
  Summary: MBX AI SDK
5
5
  Project-URL: Homepage, https://www.mibexx.de
6
6
  Project-URL: Documentation, https://www.mibexx.de
@@ -1,18 +1,18 @@
1
- mbxai/__init__.py,sha256=Y0TOlMhMNWJBWpYsqp-fuKo6LuQ2nlSRQ9Q4CfNQ1mM,48
1
+ mbxai/__init__.py,sha256=XGjnT5mfT2741bWJurwuPoX71kI5-dNSGNDJyUad-vo,48
2
2
  mbxai/core.py,sha256=WMvmU9TTa7M_m-qWsUew4xH8Ul6xseCZ2iBCXJTW-Bs,196
3
3
  mbxai/mcp/__init__.py,sha256=_ek9iYdYqW5saKetj4qDci11jxesQDiHPJRpHMKkxgU,175
4
4
  mbxai/mcp/client.py,sha256=B8ZpH-uecmTCgoDw65LwwVxsFWVoX-08t5ff0hOEPXk,6011
5
5
  mbxai/mcp/example.py,sha256=oaol7AvvZnX86JWNz64KvPjab5gg1VjVN3G8eFSzuaE,2350
6
- mbxai/mcp/server.py,sha256=xtialyKJMkHnggu26AseV0BfCzY36xQgQ7DxcOYeLXM,3463
6
+ mbxai/mcp/server.py,sha256=fg0IE9ANDjb4JcgbY7Ox73VOoSjCGVQJFwb8REzRQ3s,3463
7
7
  mbxai/openrouter/__init__.py,sha256=Ito9Qp_B6q-RLGAQcYyTJVWwR2YAZvNqE-HIYXxhtD8,298
8
- mbxai/openrouter/client.py,sha256=XLRMRNRJH96Jl6_af0KkzRDdLJnixh8I3RvEEcFuXyg,10840
8
+ mbxai/openrouter/client.py,sha256=S0FzTwiyqezhCzp2eKJHoCrAmmX1H8dKZajLu2ly18k,9661
9
9
  mbxai/openrouter/config.py,sha256=MTX_YHsFrM7JYqovJSkEF6JzVyIdajeI5Dja2CALH58,2874
10
10
  mbxai/openrouter/models.py,sha256=b3IjjtZAjeGOf2rLsdnCD1HacjTnS8jmv_ZXorc-KJQ,2604
11
11
  mbxai/tools/__init__.py,sha256=QUFaXhDm-UKcuAtT1rbKzhBkvyRBVokcQIOf9cxIuwc,160
12
12
  mbxai/tools/client.py,sha256=t7rdITqgCbDXQPFOZhGj6VDDPAwqdilJMKPfCOcJaFo,17279
13
13
  mbxai/tools/example.py,sha256=1HgKK39zzUuwFbnp3f0ThyWVfA_8P28PZcTwaUw5K78,2232
14
14
  mbxai/tools/types.py,sha256=fo5t9UbsHGynhA88vD_ecgDqL8iLvt2E1h1ym43Rrgk,745
15
- mbxai-0.5.22.dist-info/METADATA,sha256=aIlB2mJ22tPjTPwU5CsUYXkr9_R4pe0xCKXfe54KotY,4108
16
- mbxai-0.5.22.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
17
- mbxai-0.5.22.dist-info/licenses/LICENSE,sha256=hEyhc4FxwYo3NQ40yNgZ7STqwVk-1_XcTXOnAPbGJAw,1069
18
- mbxai-0.5.22.dist-info/RECORD,,
15
+ mbxai-0.5.23.dist-info/METADATA,sha256=9Wxoifgnpdi99EM7ERyGzybUI1__7dluzbjMLDvgfE4,4108
16
+ mbxai-0.5.23.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
17
+ mbxai-0.5.23.dist-info/licenses/LICENSE,sha256=hEyhc4FxwYo3NQ40yNgZ7STqwVk-1_XcTXOnAPbGJAw,1069
18
+ mbxai-0.5.23.dist-info/RECORD,,
File without changes