ractogateway.tools.registry
Tool Registry — convert Python functions and Pydantic models into tool schemas.
Users should never hand-write nested JSON dicts for function-calling. Instead,
they decorate plain Python functions with @tool or register Pydantic models
directly. Each LLM adapter then translates the registry’s canonical schema
into the provider-specific format it needs.
- class ractogateway.tools.registry.ParamSchema(**data)[source]
Bases:
BaseModelSchema for a single function parameter.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- name: str
- type: str
- description: str
- required: bool
- default: Any
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ractogateway.tools.registry.ToolSchema(**data)[source]
Bases:
BaseModelProvider-agnostic canonical representation of a callable tool.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- name: str
- description: str
- parameters: list[ParamSchema]
- to_json_schema()[source]
Return an OpenAI-compatible JSON Schema
parametersobject.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- ractogateway.tools.registry.tool(fn=None, *, name=None, description=None, registry=None)[source]
Decorator that marks a function as an LLM-callable tool.
Can be used bare (
@tool) or with overrides (@tool(name="my_tool", description="…")).You can also bind registration directly:
@tool(registry)or@tool(registry=registry).The decorated function gains a
_tool_schemaattribute containing the canonicalToolSchema.
- class ractogateway.tools.registry.ToolRegistry[source]
Bases:
objectA registry that collects tools and exposes them as canonical schemas.
Usage:
registry = ToolRegistry() @registry.register def get_weather(city: str, unit: str = "celsius") -> str: '''Get the current weather for a city.''' ... # Or register a Pydantic model: registry.register(WeatherRequest) # Iterate schemas: for schema in registry.schemas: print(schema.name)
- register(target=None, *, name=None, description=None)[source]
Register a function or Pydantic model as a tool.
Works as a decorator (
@registry.register) or as a direct call (registry.register(MyModel)).
- property schemas: list[ToolSchema]
Return all registered tool schemas.
- property tools: dict[str, ToolSchema]
Backward-compatible mapping of tool name -> schema.
- get_schema(name)[source]
Look up a single tool schema by name.
- Return type: