mbxai 1.0.2__py3-none-any.whl → 1.0.4__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__ = "1.0.2"
5
+ __version__ = "1.0.4"
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="1.0.2",
34
+ version="1.0.4",
35
35
  )
36
36
 
37
37
  # Initialize MCP server
@@ -268,6 +268,8 @@ class OpenRouterClient:
268
268
 
269
269
  response = self._client.beta.chat.completions.parse(**request)
270
270
 
271
+ logger.debug(f"Full Response: {response}")
272
+
271
273
  if response is None:
272
274
  logger.error("Received None response from OpenRouter API")
273
275
  raise OpenRouterAPIError("Received None response from OpenRouter API")
@@ -275,10 +277,38 @@ class OpenRouterClient:
275
277
  logger.info(f"Response type: {type(response)}")
276
278
  logger.info(f"Response attributes: {dir(response)}")
277
279
 
280
+ # Validate response structure
278
281
  if not hasattr(response, 'choices'):
279
282
  logger.error(f"Response missing 'choices' attribute. Available attributes: {dir(response)}")
280
283
  raise OpenRouterAPIError("Invalid response format: missing 'choices' attribute")
281
-
284
+
285
+ if not response.choices:
286
+ logger.error("Response has empty choices list")
287
+ raise OpenRouterAPIError("Invalid response format: empty choices list")
288
+
289
+ if not hasattr(response.choices[0], 'message'):
290
+ logger.error(f"First choice missing 'message' attribute. Available attributes: {dir(response.choices[0])}")
291
+ raise OpenRouterAPIError("Invalid response format: missing 'message' attribute in first choice")
292
+
293
+ # Check if the message has a parsed attribute or content
294
+ if not hasattr(response.choices[0].message, 'parsed') and not hasattr(response.choices[0].message, 'content'):
295
+ logger.error(f"Message missing both 'parsed' and 'content' attributes. Available attributes: {dir(response.choices[0].message)}")
296
+ raise OpenRouterAPIError("Invalid response format: message must have either 'parsed' or 'content' attribute")
297
+
298
+ # If there's no parsed attribute but there is content, try to parse it
299
+ if not hasattr(response.choices[0].message, 'parsed') and hasattr(response.choices[0].message, 'content'):
300
+ try:
301
+ import json
302
+ content = response.choices[0].message.content
303
+ if isinstance(content, str):
304
+ parsed = json.loads(content)
305
+ response.choices[0].message.parsed = parsed
306
+ else:
307
+ response.choices[0].message.parsed = content
308
+ except Exception as e:
309
+ logger.error(f"Failed to parse message content: {str(e)}")
310
+ raise OpenRouterAPIError(f"Failed to parse message content: {str(e)}")
311
+
282
312
  logger.info(f"Received response from OpenRouter: {len(response.choices)} choices")
283
313
 
284
314
  return response
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mbxai
3
- Version: 1.0.2
3
+ Version: 1.0.4
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,4 +1,4 @@
1
- mbxai/__init__.py,sha256=-I0HyEmjjbbpTC3NC9hqSs-XBcNr-32v1_As9l5WCp4,47
1
+ mbxai/__init__.py,sha256=XzGFmBQKNcVWwRnlgZASYHz0tK5OBVCbiPbH70sElQA,47
2
2
  mbxai/core.py,sha256=WMvmU9TTa7M_m-qWsUew4xH8Ul6xseCZ2iBCXJTW-Bs,196
3
3
  mbxai/examples/openrouter_example.py,sha256=-grXHKMmFLoh-yUIEMc31n8Gg1S7uSazBWCIOWxgbyQ,1317
4
4
  mbxai/examples/parse_example.py,sha256=eCKMJoOl6qwo8sDP6Trc6ncgjPlgTqi5tPE2kB5_P0k,3821
@@ -9,16 +9,16 @@ mbxai/examples/mcp/mcp_server_example.py,sha256=BK2kaKncyeZ9KHvrBBPGZwNATVNgTFkQ
9
9
  mbxai/mcp/__init__.py,sha256=_ek9iYdYqW5saKetj4qDci11jxesQDiHPJRpHMKkxgU,175
10
10
  mbxai/mcp/client.py,sha256=BuKmKTupzbiLMFghseeYE6Ih6xCesJ8mIMHaXHiNwlo,5206
11
11
  mbxai/mcp/example.py,sha256=oaol7AvvZnX86JWNz64KvPjab5gg1VjVN3G8eFSzuaE,2350
12
- mbxai/mcp/server.py,sha256=4jE1_bfkye8SDAfz0FrcLN-T7omYHAaazBOMQEEWmzI,3462
12
+ mbxai/mcp/server.py,sha256=NA4D5ydB8we7yFdES0cw9JkHDSC775veyX5Jxo8tQK0,3462
13
13
  mbxai/openrouter/__init__.py,sha256=Ito9Qp_B6q-RLGAQcYyTJVWwR2YAZvNqE-HIYXxhtD8,298
14
- mbxai/openrouter/client.py,sha256=d5oS5_8zjgE28Q-MTlPL5sxZBxw23TNzZ5TcjE2v3FE,12563
14
+ mbxai/openrouter/client.py,sha256=saF1w6Oep-pzzKF96oSD5is7kTMKqhbOWBMpsW746uY,14466
15
15
  mbxai/openrouter/config.py,sha256=Ia93s-auim9Sq71eunVDbn9ET5xX2zusXpV4JBdHAzs,3251
16
16
  mbxai/openrouter/models.py,sha256=b3IjjtZAjeGOf2rLsdnCD1HacjTnS8jmv_ZXorc-KJQ,2604
17
17
  mbxai/tools/__init__.py,sha256=ogxrHvgJ7OR62Lmd5x9Eh5d2C0jqWyQis7Zy3yKpZ78,218
18
18
  mbxai/tools/client.py,sha256=h_1fxVDBq57f_OXNsj-TBp6-r367sv6Z5nk1qLFcLO8,14951
19
19
  mbxai/tools/example.py,sha256=1HgKK39zzUuwFbnp3f0ThyWVfA_8P28PZcTwaUw5K78,2232
20
20
  mbxai/tools/types.py,sha256=yUMvRlWiFy2KnEQLCerh4XioVKMKa2wHtb3fCDybg34,5878
21
- mbxai-1.0.2.dist-info/METADATA,sha256=lscyqhbBG6lBaL3gGcflcDA2eeTyWbRCUWdkz35M6WE,4147
22
- mbxai-1.0.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
- mbxai-1.0.2.dist-info/licenses/LICENSE,sha256=hEyhc4FxwYo3NQ40yNgZ7STqwVk-1_XcTXOnAPbGJAw,1069
24
- mbxai-1.0.2.dist-info/RECORD,,
21
+ mbxai-1.0.4.dist-info/METADATA,sha256=RUhJExgMshpClZP1w_JHVRxBs6jKoofWYW8Fb8sXITU,4147
22
+ mbxai-1.0.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
+ mbxai-1.0.4.dist-info/licenses/LICENSE,sha256=hEyhc4FxwYo3NQ40yNgZ7STqwVk-1_XcTXOnAPbGJAw,1069
24
+ mbxai-1.0.4.dist-info/RECORD,,
File without changes