mbxai 0.5.21__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 +1 -1
- mbxai/mcp/client.py +13 -1
- mbxai/mcp/server.py +1 -1
- mbxai/openrouter/client.py +19 -52
- {mbxai-0.5.21.dist-info → mbxai-0.5.23.dist-info}/METADATA +1 -1
- {mbxai-0.5.21.dist-info → mbxai-0.5.23.dist-info}/RECORD +8 -8
- {mbxai-0.5.21.dist-info → mbxai-0.5.23.dist-info}/WHEEL +0 -0
- {mbxai-0.5.21.dist-info → mbxai-0.5.23.dist-info}/licenses/LICENSE +0 -0
mbxai/__init__.py
CHANGED
mbxai/mcp/client.py
CHANGED
@@ -93,7 +93,19 @@ class MCPClient(ToolClient):
|
|
93
93
|
json={"input": kwargs} if tool.strict else kwargs,
|
94
94
|
timeout=300.0 # 5 minutes timeout
|
95
95
|
)
|
96
|
-
|
96
|
+
|
97
|
+
# Log response details for debugging
|
98
|
+
logger.info(f"Tool {tool.name} response status: {response.status_code}")
|
99
|
+
logger.info(f"Tool {tool.name} response headers: {response.headers}")
|
100
|
+
|
101
|
+
try:
|
102
|
+
result = response.json()
|
103
|
+
logger.info(f"Tool {tool.name} response parsed successfully")
|
104
|
+
return result
|
105
|
+
except Exception as e:
|
106
|
+
logger.error(f"Failed to parse tool {tool.name} response: {str(e)}")
|
107
|
+
logger.error(f"Response content: {response.text[:1000]}...") # Log first 1000 chars
|
108
|
+
raise
|
97
109
|
|
98
110
|
return tool_function
|
99
111
|
|
mbxai/mcp/server.py
CHANGED
mbxai/openrouter/client.py
CHANGED
@@ -115,74 +115,41 @@ class OpenRouterClient:
|
|
115
115
|
self,
|
116
116
|
messages: list[dict[str, Any]],
|
117
117
|
*,
|
118
|
-
model:
|
118
|
+
model: str | None = None,
|
119
119
|
stream: bool = False,
|
120
120
|
**kwargs: Any,
|
121
121
|
) -> Any:
|
122
|
-
"""
|
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
|
-
#
|
140
|
-
|
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
|
154
|
-
logger.
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
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
|
185
|
-
|
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,18 +1,18 @@
|
|
1
|
-
mbxai/__init__.py,sha256=
|
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
|
-
mbxai/mcp/client.py,sha256=
|
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=
|
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=
|
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.
|
16
|
-
mbxai-0.5.
|
17
|
-
mbxai-0.5.
|
18
|
-
mbxai-0.5.
|
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
|
File without changes
|