mbxai 0.6.19__tar.gz → 0.6.21__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.
Files changed (25) hide show
  1. {mbxai-0.6.19 → mbxai-0.6.21}/PKG-INFO +1 -1
  2. {mbxai-0.6.19 → mbxai-0.6.21}/pyproject.toml +1 -1
  3. {mbxai-0.6.19 → mbxai-0.6.21}/setup.py +1 -1
  4. {mbxai-0.6.19 → mbxai-0.6.21}/src/mbxai/__init__.py +1 -1
  5. {mbxai-0.6.19 → mbxai-0.6.21}/src/mbxai/mcp/client.py +9 -13
  6. {mbxai-0.6.19 → mbxai-0.6.21}/src/mbxai/mcp/server.py +1 -1
  7. {mbxai-0.6.19 → mbxai-0.6.21}/src/mbxai/tools/types.py +15 -1
  8. {mbxai-0.6.19 → mbxai-0.6.21}/uv.lock +1 -1
  9. {mbxai-0.6.19 → mbxai-0.6.21}/.gitignore +0 -0
  10. {mbxai-0.6.19 → mbxai-0.6.21}/LICENSE +0 -0
  11. {mbxai-0.6.19 → mbxai-0.6.21}/README.md +0 -0
  12. {mbxai-0.6.19 → mbxai-0.6.21}/src/mbxai/core.py +0 -0
  13. {mbxai-0.6.19 → mbxai-0.6.21}/src/mbxai/mcp/__init__.py +0 -0
  14. {mbxai-0.6.19 → mbxai-0.6.21}/src/mbxai/mcp/example.py +0 -0
  15. {mbxai-0.6.19 → mbxai-0.6.21}/src/mbxai/openrouter/__init__.py +0 -0
  16. {mbxai-0.6.19 → mbxai-0.6.21}/src/mbxai/openrouter/client.py +0 -0
  17. {mbxai-0.6.19 → mbxai-0.6.21}/src/mbxai/openrouter/config.py +0 -0
  18. {mbxai-0.6.19 → mbxai-0.6.21}/src/mbxai/openrouter/models.py +0 -0
  19. {mbxai-0.6.19 → mbxai-0.6.21}/src/mbxai/tools/__init__.py +0 -0
  20. {mbxai-0.6.19 → mbxai-0.6.21}/src/mbxai/tools/client.py +0 -0
  21. {mbxai-0.6.19 → mbxai-0.6.21}/src/mbxai/tools/example.py +0 -0
  22. {mbxai-0.6.19 → mbxai-0.6.21}/tests/test_core.py +0 -0
  23. {mbxai-0.6.19 → mbxai-0.6.21}/tests/test_mcp.py +0 -0
  24. {mbxai-0.6.19 → mbxai-0.6.21}/tests/test_openrouter.py +0 -0
  25. {mbxai-0.6.19 → mbxai-0.6.21}/tests/test_tools.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mbxai
3
- Version: 0.6.19
3
+ Version: 0.6.21
4
4
  Summary: MBX AI SDK
5
5
  Project-URL: Homepage, https://www.mibexx.de
6
6
  Project-URL: Documentation, https://www.mibexx.de
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "mbxai"
7
- version = "0.6.19"
7
+ version = "0.6.21"
8
8
  authors = [
9
9
  { name = "MBX AI" }
10
10
  ]
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="mbxai",
5
- version="0.6.19",
5
+ version="0.6.21",
6
6
  author="MBX AI",
7
7
  description="MBX AI SDK",
8
8
  long_description=open("README.md").read(),
@@ -2,4 +2,4 @@
2
2
  MBX AI package.
3
3
  """
4
4
 
5
- __version__ = "0.6.19"
5
+ __version__ = "0.6.21"
@@ -16,28 +16,24 @@ 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
23
+ function: Callable[..., Any] | None = None # Make function optional during initialization
26
24
 
27
25
  def to_openai_function(self) -> dict[str, Any]:
28
26
  """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)}")
27
+ # Use the base Tool's schema conversion
28
+ strict_schema = convert_to_strict_schema(self.input_schema, strict=self.strict)
29
+ logger.info(f"Converted schema for {self.name}: {json.dumps(strict_schema, indent=2)}")
34
30
 
35
31
  return {
36
32
  "type": "function",
37
33
  "function": {
38
34
  "name": self.name,
39
35
  "description": self.description,
40
- "parameters": self._converted_schema
36
+ "parameters": strict_schema
41
37
  }
42
38
  }
43
39
 
@@ -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.21",
35
35
  )
36
36
 
37
37
  # Initialize MCP server
@@ -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):
@@ -88,13 +101,14 @@ class Tool(BaseModel):
88
101
  """A tool that can be used by the model."""
89
102
  name: str
90
103
  description: str
91
- function: Callable[..., Any]
104
+ function: Callable[..., Any] | None = None # Make function optional
92
105
  schema: dict[str, Any]
93
106
 
94
107
  def to_openai_function(self) -> dict[str, Any]:
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",
@@ -446,7 +446,7 @@ wheels = [
446
446
 
447
447
  [[package]]
448
448
  name = "mbxai"
449
- version = "0.6.19"
449
+ version = "0.6.21"
450
450
  source = { editable = "." }
451
451
  dependencies = [
452
452
  { name = "fastapi" },
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