mbxai 0.6.23__tar.gz → 0.6.25__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-0.6.23 → mbxai-0.6.25}/PKG-INFO +1 -1
- {mbxai-0.6.23 → mbxai-0.6.25}/pyproject.toml +1 -1
- {mbxai-0.6.23 → mbxai-0.6.25}/setup.py +1 -1
- {mbxai-0.6.23 → mbxai-0.6.25}/src/mbxai/__init__.py +1 -1
- {mbxai-0.6.23 → mbxai-0.6.25}/src/mbxai/mcp/server.py +1 -1
- {mbxai-0.6.23 → mbxai-0.6.25}/src/mbxai/tools/types.py +10 -35
- {mbxai-0.6.23 → mbxai-0.6.25}/uv.lock +1 -1
- {mbxai-0.6.23 → mbxai-0.6.25}/.gitignore +0 -0
- {mbxai-0.6.23 → mbxai-0.6.25}/LICENSE +0 -0
- {mbxai-0.6.23 → mbxai-0.6.25}/README.md +0 -0
- {mbxai-0.6.23 → mbxai-0.6.25}/src/mbxai/core.py +0 -0
- {mbxai-0.6.23 → mbxai-0.6.25}/src/mbxai/mcp/__init__.py +0 -0
- {mbxai-0.6.23 → mbxai-0.6.25}/src/mbxai/mcp/client.py +0 -0
- {mbxai-0.6.23 → mbxai-0.6.25}/src/mbxai/mcp/example.py +0 -0
- {mbxai-0.6.23 → mbxai-0.6.25}/src/mbxai/openrouter/__init__.py +0 -0
- {mbxai-0.6.23 → mbxai-0.6.25}/src/mbxai/openrouter/client.py +0 -0
- {mbxai-0.6.23 → mbxai-0.6.25}/src/mbxai/openrouter/config.py +0 -0
- {mbxai-0.6.23 → mbxai-0.6.25}/src/mbxai/openrouter/models.py +0 -0
- {mbxai-0.6.23 → mbxai-0.6.25}/src/mbxai/tools/__init__.py +0 -0
- {mbxai-0.6.23 → mbxai-0.6.25}/src/mbxai/tools/client.py +0 -0
- {mbxai-0.6.23 → mbxai-0.6.25}/src/mbxai/tools/example.py +0 -0
- {mbxai-0.6.23 → mbxai-0.6.25}/tests/test_core.py +0 -0
- {mbxai-0.6.23 → mbxai-0.6.25}/tests/test_mcp.py +0 -0
- {mbxai-0.6.23 → mbxai-0.6.25}/tests/test_openrouter.py +0 -0
- {mbxai-0.6.23 → mbxai-0.6.25}/tests/test_tools.py +0 -0
@@ -20,9 +20,6 @@ def convert_to_strict_schema(schema: dict[str, Any], strict: bool = True, keep_i
|
|
20
20
|
Returns:
|
21
21
|
A schema in strict format
|
22
22
|
"""
|
23
|
-
logger.info(f"Converting schema to strict format. Input schema: {json.dumps(schema, indent=2)}")
|
24
|
-
logger.info(f"Strict mode: {strict}, Keep input wrapper: {keep_input_wrapper}")
|
25
|
-
|
26
23
|
if not schema:
|
27
24
|
return {"type": "object", "properties": {}, "required": []}
|
28
25
|
|
@@ -40,13 +37,11 @@ def convert_to_strict_schema(schema: dict[str, Any], strict: bool = True, keep_i
|
|
40
37
|
# Handle input wrapper
|
41
38
|
if "properties" in schema and "input" in schema["properties"]:
|
42
39
|
input_schema = schema["properties"]["input"]
|
43
|
-
logger.info(f"Found input wrapper. Input schema: {json.dumps(input_schema, indent=2)}")
|
44
40
|
|
45
41
|
# If input has a $ref, resolve it
|
46
42
|
if "$ref" in input_schema:
|
47
43
|
ref = input_schema["$ref"].split("/")[-1]
|
48
44
|
input_schema = schema.get("$defs", {}).get(ref, {})
|
49
|
-
logger.info(f"Resolved $ref to: {json.dumps(input_schema, indent=2)}")
|
50
45
|
|
51
46
|
if keep_input_wrapper:
|
52
47
|
# Create the input property schema
|
@@ -63,24 +58,17 @@ def convert_to_strict_schema(schema: dict[str, Any], strict: bool = True, keep_i
|
|
63
58
|
# Copy over input properties
|
64
59
|
if "properties" in input_schema:
|
65
60
|
for prop_name, prop in input_schema["properties"].items():
|
66
|
-
# Create a new property object with
|
61
|
+
# Create a new property object with only allowed fields
|
67
62
|
new_prop = {
|
68
63
|
"type": prop.get("type", "string"),
|
69
64
|
"description": prop.get("description", f"The {prop_name} parameter")
|
70
65
|
}
|
71
66
|
|
72
|
-
# Copy over any additional fields that might be useful
|
73
|
-
for key, value in prop.items():
|
74
|
-
if key not in new_prop:
|
75
|
-
new_prop[key] = value
|
76
|
-
|
77
67
|
input_prop_schema["properties"][prop_name] = new_prop
|
78
|
-
logger.info(f"Added property {prop_name}: {json.dumps(new_prop, indent=2)}")
|
79
68
|
|
80
69
|
# Copy over required fields for input schema
|
81
70
|
if "required" in input_schema:
|
82
71
|
input_prop_schema["required"] = input_schema["required"]
|
83
|
-
logger.info(f"Added required fields for input schema: {input_prop_schema['required']}")
|
84
72
|
|
85
73
|
# Add the input property to the main schema
|
86
74
|
strict_schema["properties"]["input"] = input_prop_schema
|
@@ -88,53 +76,37 @@ def convert_to_strict_schema(schema: dict[str, Any], strict: bool = True, keep_i
|
|
88
76
|
# Copy over required fields for main schema
|
89
77
|
if "required" in schema:
|
90
78
|
strict_schema["required"] = schema["required"]
|
91
|
-
logger.info(f"Added required fields for main schema: {strict_schema['required']}")
|
92
79
|
else:
|
93
80
|
# If not keeping input wrapper, use input schema directly
|
94
81
|
if "properties" in input_schema:
|
95
82
|
for prop_name, prop in input_schema["properties"].items():
|
96
|
-
# Create a new property object with
|
83
|
+
# Create a new property object with only allowed fields
|
97
84
|
new_prop = {
|
98
85
|
"type": prop.get("type", "string"),
|
99
86
|
"description": prop.get("description", f"The {prop_name} parameter")
|
100
87
|
}
|
101
88
|
|
102
|
-
# Copy over any additional fields that might be useful
|
103
|
-
for key, value in prop.items():
|
104
|
-
if key not in new_prop:
|
105
|
-
new_prop[key] = value
|
106
|
-
|
107
89
|
strict_schema["properties"][prop_name] = new_prop
|
108
|
-
logger.info(f"Added property {prop_name}: {json.dumps(new_prop, indent=2)}")
|
109
90
|
|
110
91
|
# Copy over required fields
|
111
92
|
if "required" in input_schema:
|
112
93
|
strict_schema["required"] = input_schema["required"]
|
113
|
-
logger.info(f"Added required fields: {strict_schema['required']}")
|
114
94
|
else:
|
115
95
|
# If no input wrapper, use the schema as is
|
116
96
|
if "properties" in schema:
|
117
97
|
for prop_name, prop in schema["properties"].items():
|
118
|
-
# Create a new property object with
|
98
|
+
# Create a new property object with only allowed fields
|
119
99
|
new_prop = {
|
120
100
|
"type": prop.get("type", "string"),
|
121
101
|
"description": prop.get("description", f"The {prop_name} parameter")
|
122
102
|
}
|
123
103
|
|
124
|
-
# Copy over any additional fields that might be useful
|
125
|
-
for key, value in prop.items():
|
126
|
-
if key not in new_prop:
|
127
|
-
new_prop[key] = value
|
128
|
-
|
129
104
|
strict_schema["properties"][prop_name] = new_prop
|
130
|
-
logger.info(f"Added property {prop_name}: {json.dumps(new_prop, indent=2)}")
|
131
105
|
|
132
106
|
# Copy over required fields
|
133
107
|
if "required" in schema:
|
134
108
|
strict_schema["required"] = schema["required"]
|
135
|
-
logger.info(f"Added required fields: {strict_schema['required']}")
|
136
109
|
|
137
|
-
logger.info(f"Final strict schema: {json.dumps(strict_schema, indent=2)}")
|
138
110
|
return strict_schema
|
139
111
|
|
140
112
|
class ToolCall(BaseModel):
|
@@ -154,13 +126,16 @@ class Tool(BaseModel):
|
|
154
126
|
"""Convert the tool to an OpenAI function definition."""
|
155
127
|
# Ensure schema is in strict format
|
156
128
|
strict_schema = convert_to_strict_schema(self.schema)
|
157
|
-
logger.info(f"Converted schema for {self.name}: {json.dumps(strict_schema, indent=2)}")
|
158
129
|
|
159
|
-
|
130
|
+
function_def = {
|
160
131
|
"type": "function",
|
161
132
|
"function": {
|
162
133
|
"name": self.name,
|
163
134
|
"description": self.description,
|
164
|
-
"parameters": strict_schema
|
135
|
+
"parameters": strict_schema,
|
136
|
+
"strict": True
|
165
137
|
}
|
166
|
-
}
|
138
|
+
}
|
139
|
+
|
140
|
+
logger.info(f"Created function definition for {self.name}: {json.dumps(function_def, indent=2)}")
|
141
|
+
return function_def
|
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
|