Metadata-Version: 2.4
Name: matrix-fn-schema
Version: 0.1.1
Summary: Python function signatures to OpenAI-compatible JSON Schema
License-Expression: MIT
Keywords: openai,json-schema,function-calling,tools
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: docstring-parser>=0.16
Provides-Extra: pydantic
Requires-Dist: pydantic>=2; extra == "pydantic"
Dynamic: license-file

# matrix-fn-schema

Convert Python function signatures (type annotations + docstrings) into OpenAI-compatible JSON Schema (tool call format).

```python
from matrix_fn_schema import build_json_schema


def get_weather(city: str, units: Literal["metric", "imperial"] = "metric") -> str:
    """Get the current weather for a city."""
    ...


schema = build_json_schema(get_weather)
# {
#   "type": "function",
#   "name": "get_weather",
#   "description": "Get the current weather for a city.",
#   "strict": True,
#   "parameters": {
#     "type": "object",
#     "properties": {
#       "city": {"type": "string"},
#       "units": {"anyOf": [{"enum": ["metric", "imperial"]}, {"type": "null"}]}
#     },
#     "additionalProperties": False,
#     "required": ["city", "units"]
#   }
# }
```

Supports: `int`, `float`, `str`, `bool`, `None`, `Optional[X]`, `Union[...]`, `Literal[...]`, `list[X]`, `tuple[X, ...]`, `dict[K, V]`, nested `pydantic.BaseModel`.

Requires Python 3.10+.

Written with love by dotmatrix.
