ractogateway.tools
ractogateway.tools — Tool Registry & Schema Builder.
Provides a ToolRegistry that accepts standard Python functions (via a
@tool decorator) or Pydantic models and translates them into
provider-specific tool/function-calling schemas.
- class ractogateway.tools.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:
- class ractogateway.tools.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.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.