mbxai 0.5.3__py3-none-any.whl → 0.5.5__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 +6 -3
- mbxai/mcp/server.py +1 -1
- mbxai/tools/client.py +14 -10
- mbxai/tools/types.py +8 -11
- {mbxai-0.5.3.dist-info → mbxai-0.5.5.dist-info}/METADATA +1 -1
- {mbxai-0.5.3.dist-info → mbxai-0.5.5.dist-info}/RECORD +9 -9
- {mbxai-0.5.3.dist-info → mbxai-0.5.5.dist-info}/WHEEL +0 -0
- {mbxai-0.5.3.dist-info → mbxai-0.5.5.dist-info}/licenses/LICENSE +0 -0
mbxai/__init__.py
CHANGED
mbxai/mcp/client.py
CHANGED
@@ -24,9 +24,12 @@ class MCPTool(Tool):
|
|
24
24
|
def to_openai_function(self) -> dict[str, Any]:
|
25
25
|
"""Convert the tool to an OpenAI function definition."""
|
26
26
|
return {
|
27
|
-
"
|
28
|
-
"
|
29
|
-
|
27
|
+
"type": "function",
|
28
|
+
"function": {
|
29
|
+
"name": self.name,
|
30
|
+
"description": self.description,
|
31
|
+
"parameters": self._convert_to_openai_schema(self.input_schema)
|
32
|
+
}
|
30
33
|
}
|
31
34
|
|
32
35
|
def _convert_to_openai_schema(self, mcp_schema: dict[str, Any]) -> dict[str, Any]:
|
mbxai/mcp/server.py
CHANGED
mbxai/tools/client.py
CHANGED
@@ -3,10 +3,13 @@ ToolClient implementation for MBX AI.
|
|
3
3
|
"""
|
4
4
|
|
5
5
|
from typing import Any, Callable, TypeVar, cast
|
6
|
+
import logging
|
6
7
|
from pydantic import BaseModel
|
7
8
|
from ..openrouter import OpenRouterClient
|
8
9
|
from .types import Tool, ToolCall
|
9
10
|
|
11
|
+
logger = logging.getLogger(__name__)
|
12
|
+
|
10
13
|
T = TypeVar("T", bound=BaseModel)
|
11
14
|
|
12
15
|
class ToolClient:
|
@@ -43,6 +46,7 @@ class ToolClient:
|
|
43
46
|
schema=schema,
|
44
47
|
)
|
45
48
|
self._tools[name] = tool
|
49
|
+
logger.debug(f"Registered tool: {name}")
|
46
50
|
|
47
51
|
def chat(
|
48
52
|
self,
|
@@ -65,12 +69,12 @@ class ToolClient:
|
|
65
69
|
"""
|
66
70
|
tools = [tool.to_openai_function() for tool in self._tools.values()]
|
67
71
|
|
72
|
+
if tools:
|
73
|
+
logger.debug(f"Using tools: {tools}")
|
74
|
+
kwargs["tools"] = tools
|
75
|
+
kwargs["tool_choice"] = "auto"
|
76
|
+
|
68
77
|
while True:
|
69
|
-
# Add tools to the request if we have any
|
70
|
-
if tools:
|
71
|
-
kwargs["tools"] = tools
|
72
|
-
kwargs["tool_choice"] = "auto"
|
73
|
-
|
74
78
|
# Get the model's response
|
75
79
|
response = self._client.chat_completion(
|
76
80
|
messages=messages,
|
@@ -129,12 +133,12 @@ class ToolClient:
|
|
129
133
|
"""
|
130
134
|
tools = [tool.to_openai_function() for tool in self._tools.values()]
|
131
135
|
|
136
|
+
if tools:
|
137
|
+
logger.debug(f"Using tools: {tools}")
|
138
|
+
kwargs["tools"] = tools
|
139
|
+
kwargs["tool_choice"] = "auto"
|
140
|
+
|
132
141
|
while True:
|
133
|
-
# Add tools to the request if we have any
|
134
|
-
if tools:
|
135
|
-
kwargs["tools"] = tools
|
136
|
-
kwargs["tool_choice"] = "auto"
|
137
|
-
|
138
142
|
# Get the model's response
|
139
143
|
response = self._client.chat_completion_parse(
|
140
144
|
messages=messages,
|
mbxai/tools/types.py
CHANGED
@@ -2,15 +2,9 @@
|
|
2
2
|
Type definitions for the tools package.
|
3
3
|
"""
|
4
4
|
|
5
|
-
from typing import Any, Callable
|
5
|
+
from typing import Any, Callable
|
6
6
|
from pydantic import BaseModel
|
7
7
|
|
8
|
-
class ToolFunction(TypedDict):
|
9
|
-
"""OpenAI function definition for a tool."""
|
10
|
-
name: str
|
11
|
-
description: str
|
12
|
-
parameters: dict[str, Any]
|
13
|
-
|
14
8
|
class ToolCall(BaseModel):
|
15
9
|
"""A tool call from the model."""
|
16
10
|
id: str
|
@@ -24,10 +18,13 @@ class Tool(BaseModel):
|
|
24
18
|
function: Callable[..., Any]
|
25
19
|
schema: dict[str, Any]
|
26
20
|
|
27
|
-
def to_openai_function(self) ->
|
21
|
+
def to_openai_function(self) -> dict[str, Any]:
|
28
22
|
"""Convert the tool to an OpenAI function definition."""
|
29
23
|
return {
|
30
|
-
"
|
31
|
-
"
|
32
|
-
|
24
|
+
"type": "function",
|
25
|
+
"function": {
|
26
|
+
"name": self.name,
|
27
|
+
"description": self.description,
|
28
|
+
"parameters": self.schema
|
29
|
+
}
|
33
30
|
}
|
@@ -1,18 +1,18 @@
|
|
1
|
-
mbxai/__init__.py,sha256=
|
1
|
+
mbxai/__init__.py,sha256=9R6hwrMZv42Y8AiBgP0KTxJvokh8rDG_HHmedMSnNDE,47
|
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=QxVeQRBQryeEGXDU8X_9qQBfT-ubDd9L9KSc5-P354U,5590
|
5
5
|
mbxai/mcp/example.py,sha256=oaol7AvvZnX86JWNz64KvPjab5gg1VjVN3G8eFSzuaE,2350
|
6
|
-
mbxai/mcp/server.py,sha256=
|
6
|
+
mbxai/mcp/server.py,sha256=EJwK4GRsUG2xLfZocFsHpp31qu4GGWvwH7s50AG4qH8,3462
|
7
7
|
mbxai/openrouter/__init__.py,sha256=Ito9Qp_B6q-RLGAQcYyTJVWwR2YAZvNqE-HIYXxhtD8,298
|
8
8
|
mbxai/openrouter/client.py,sha256=XLRMRNRJH96Jl6_af0KkzRDdLJnixh8I3RvEEcFuXyg,10840
|
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
|
-
mbxai/tools/client.py,sha256=
|
12
|
+
mbxai/tools/client.py,sha256=t4qjiKtWeiV5s6Dj_eh7VLm1YmmKN2zVMDAf6DRmADw,5504
|
13
13
|
mbxai/tools/example.py,sha256=1HgKK39zzUuwFbnp3f0ThyWVfA_8P28PZcTwaUw5K78,2232
|
14
|
-
mbxai/tools/types.py,sha256=
|
15
|
-
mbxai-0.5.
|
16
|
-
mbxai-0.5.
|
17
|
-
mbxai-0.5.
|
18
|
-
mbxai-0.5.
|
14
|
+
mbxai/tools/types.py,sha256=fo5t9UbsHGynhA88vD_ecgDqL8iLvt2E1h1ym43Rrgk,745
|
15
|
+
mbxai-0.5.5.dist-info/METADATA,sha256=EwoHlZOsXYdG8fI7uEXu-sA2uHqeKP_k3vaGUo-sp8M,4107
|
16
|
+
mbxai-0.5.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
17
|
+
mbxai-0.5.5.dist-info/licenses/LICENSE,sha256=hEyhc4FxwYo3NQ40yNgZ7STqwVk-1_XcTXOnAPbGJAw,1069
|
18
|
+
mbxai-0.5.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|