mbxai 0.6.19__py3-none-any.whl → 0.6.20__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.6.19"
5
+ __version__ = "0.6.20"
mbxai/mcp/client.py CHANGED
@@ -16,28 +16,23 @@ T = TypeVar("T", bound=BaseModel)
16
16
 
17
17
 
18
18
  class MCPTool(Tool):
19
- """MCP tool definition."""
20
- internal_url: str | None = Field(default=None, description="The internal URL to invoke the tool")
21
- service: str = Field(description="The service that provides the tool")
22
- strict: bool = Field(default=True, description="Whether the tool response is strictly validated")
23
- input_schema: dict[str, Any] = Field(description="The input schema for the tool")
24
- function: Callable[..., Any] | None = Field(default=None, description="The function that implements the tool")
25
- _converted_schema: dict[str, Any] | None = None
19
+ """A tool from the MCP server."""
20
+ input_schema: dict[str, Any]
21
+ internal_url: str
22
+ strict: bool = True
26
23
 
27
24
  def to_openai_function(self) -> dict[str, Any]:
28
25
  """Convert the tool to an OpenAI function definition."""
29
- # Use cached schema if available
30
- if self._converted_schema is None:
31
- # Convert the schema to strict format
32
- self._converted_schema = convert_to_strict_schema(self.input_schema, self.strict)
33
- logger.debug(f"Converted schema for {self.name}: {json.dumps(self._converted_schema, indent=2)}")
26
+ # Use the base Tool's schema conversion
27
+ strict_schema = convert_to_strict_schema(self.input_schema, strict=self.strict)
28
+ logger.info(f"Converted schema for {self.name}: {json.dumps(strict_schema, indent=2)}")
34
29
 
35
30
  return {
36
31
  "type": "function",
37
32
  "function": {
38
33
  "name": self.name,
39
34
  "description": self.description,
40
- "parameters": self._converted_schema
35
+ "parameters": strict_schema
41
36
  }
42
37
  }
43
38
 
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.6.19",
34
+ version="0.6.20",
35
35
  )
36
36
 
37
37
  # Initialize MCP server
mbxai/tools/types.py CHANGED
@@ -4,6 +4,10 @@ Type definitions for the tools package.
4
4
 
5
5
  from typing import Any, Callable
6
6
  from pydantic import BaseModel, Field
7
+ import logging
8
+ import json
9
+
10
+ logger = logging.getLogger(__name__)
7
11
 
8
12
  def convert_to_strict_schema(schema: dict[str, Any], strict: bool = True) -> dict[str, Any]:
9
13
  """Convert a schema to strict format required by OpenAI.
@@ -15,6 +19,9 @@ def convert_to_strict_schema(schema: dict[str, Any], strict: bool = True) -> dic
15
19
  Returns:
16
20
  A schema in strict format
17
21
  """
22
+ logger.info(f"Converting schema to strict format. Input schema: {json.dumps(schema, indent=2)}")
23
+ logger.info(f"Strict mode: {strict}")
24
+
18
25
  if not schema:
19
26
  return {"type": "object", "properties": {}, "required": []}
20
27
 
@@ -32,11 +39,13 @@ def convert_to_strict_schema(schema: dict[str, Any], strict: bool = True) -> dic
32
39
  # Handle input wrapper
33
40
  if "properties" in schema and "input" in schema["properties"]:
34
41
  input_schema = schema["properties"]["input"]
42
+ logger.info(f"Found input wrapper. Input schema: {json.dumps(input_schema, indent=2)}")
35
43
 
36
44
  # If input has a $ref, resolve it
37
45
  if "$ref" in input_schema:
38
46
  ref = input_schema["$ref"].split("/")[-1]
39
47
  input_schema = schema.get("$defs", {}).get(ref, {})
48
+ logger.info(f"Resolved $ref to: {json.dumps(input_schema, indent=2)}")
40
49
 
41
50
  # Create the input property schema
42
51
  input_prop_schema = {
@@ -64,10 +73,12 @@ def convert_to_strict_schema(schema: dict[str, Any], strict: bool = True) -> dic
64
73
  new_prop[key] = value
65
74
 
66
75
  input_prop_schema["properties"][prop_name] = new_prop
76
+ logger.info(f"Added property {prop_name}: {json.dumps(new_prop, indent=2)}")
67
77
 
68
78
  # Copy over required fields for input schema
69
79
  if "required" in input_schema:
70
80
  input_prop_schema["required"] = input_schema["required"]
81
+ logger.info(f"Added required fields for input schema: {input_prop_schema['required']}")
71
82
 
72
83
  # Add the input property to the main schema
73
84
  strict_schema["properties"]["input"] = input_prop_schema
@@ -75,7 +86,9 @@ def convert_to_strict_schema(schema: dict[str, Any], strict: bool = True) -> dic
75
86
  # Copy over required fields for main schema
76
87
  if "required" in schema:
77
88
  strict_schema["required"] = schema["required"]
89
+ logger.info(f"Added required fields for main schema: {strict_schema['required']}")
78
90
 
91
+ logger.info(f"Final strict schema: {json.dumps(strict_schema, indent=2)}")
79
92
  return strict_schema
80
93
 
81
94
  class ToolCall(BaseModel):
@@ -95,6 +108,7 @@ class Tool(BaseModel):
95
108
  """Convert the tool to an OpenAI function definition."""
96
109
  # Ensure schema is in strict format
97
110
  strict_schema = convert_to_strict_schema(self.schema)
111
+ logger.info(f"Converted schema for {self.name}: {json.dumps(strict_schema, indent=2)}")
98
112
 
99
113
  return {
100
114
  "type": "function",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mbxai
3
- Version: 0.6.19
3
+ Version: 0.6.20
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,9 +1,9 @@
1
- mbxai/__init__.py,sha256=pqQAqM2XXc5pNrLfCSIAv2P-v29FjHrtlZhI1gq_DNY,48
1
+ mbxai/__init__.py,sha256=k5Jl-pIwvz4w-b1_h3wR6y9AzjIl18Pwd10AZN-l-rk,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=PpMNZSkmdPKf7artTDLDap-C9GbPjuGmKmr1byF0l6A,8309
4
+ mbxai/mcp/client.py,sha256=UhrtsR13px-3MyfHvida5Eh_ou9-ofVexHkhMUEmYH8,7748
5
5
  mbxai/mcp/example.py,sha256=oaol7AvvZnX86JWNz64KvPjab5gg1VjVN3G8eFSzuaE,2350
6
- mbxai/mcp/server.py,sha256=xFAVMLwi7130DCJ1EdwrkFR4rQTa0O6GzuCsBfQnmM0,3463
6
+ mbxai/mcp/server.py,sha256=65DvS6RyZ59tRThiFo_bCm3C_SbagGtzkTKEAh2JLLM,3463
7
7
  mbxai/openrouter/__init__.py,sha256=Ito9Qp_B6q-RLGAQcYyTJVWwR2YAZvNqE-HIYXxhtD8,298
8
8
  mbxai/openrouter/client.py,sha256=nusxYObyLAMGQd6J9u2uLfkRXyE5kZmdIGdlU-76HPo,13529
9
9
  mbxai/openrouter/config.py,sha256=Ia93s-auim9Sq71eunVDbn9ET5xX2zusXpV4JBdHAzs,3251
@@ -11,8 +11,8 @@ mbxai/openrouter/models.py,sha256=b3IjjtZAjeGOf2rLsdnCD1HacjTnS8jmv_ZXorc-KJQ,26
11
11
  mbxai/tools/__init__.py,sha256=ogxrHvgJ7OR62Lmd5x9Eh5d2C0jqWyQis7Zy3yKpZ78,218
12
12
  mbxai/tools/client.py,sha256=qOf8MiQ8_flPUNiMioOyjeEaV8rN1EBWb98T8qTC3D4,17582
13
13
  mbxai/tools/example.py,sha256=1HgKK39zzUuwFbnp3f0ThyWVfA_8P28PZcTwaUw5K78,2232
14
- mbxai/tools/types.py,sha256=B3ujnPng997FCjQ5j25Da88ASkTDDj5gQpJRzVmdw9Q,3524
15
- mbxai-0.6.19.dist-info/METADATA,sha256=k6P9GsIx9wYDS0DVOczSwgUvepDfXxx8BCSTOBnZDpQ,4148
16
- mbxai-0.6.19.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
17
- mbxai-0.6.19.dist-info/licenses/LICENSE,sha256=hEyhc4FxwYo3NQ40yNgZ7STqwVk-1_XcTXOnAPbGJAw,1069
18
- mbxai-0.6.19.dist-info/RECORD,,
14
+ mbxai/tools/types.py,sha256=lAmy35IX04QV18Am8Ebd-0o6i34QU0vv82FaBYznu_E,4375
15
+ mbxai-0.6.20.dist-info/METADATA,sha256=BQJaUY0ZGe924fILDvEIPefVaPPyu66BFSWZ9Rc-JS8,4148
16
+ mbxai-0.6.20.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
17
+ mbxai-0.6.20.dist-info/licenses/LICENSE,sha256=hEyhc4FxwYo3NQ40yNgZ7STqwVk-1_XcTXOnAPbGJAw,1069
18
+ mbxai-0.6.20.dist-info/RECORD,,
File without changes