ractogateway.adapters
ractogateway.adapters — LLM Provider Adapters.
Implements the Adapter Design Pattern to normalize API differences across LLM providers. Each adapter translates tool schemas, handles request formatting, and standardizes response parsing.
- class ractogateway.adapters.BaseLLMAdapter(model, *, api_key=None, **kwargs)[source]
Bases:
ABCAbstract base class that every provider adapter must implement.
- Parameters:
- provider: str = 'base'
- abstractmethod translate_tools(registry)[source]
Convert canonical
ToolSchemaobjects into the provider’s native tool/function-calling format.
- abstractmethod run(prompt, user_message, *, history=None, tools=None, temperature=0.0, max_tokens=4096, **kwargs)[source]
Execute a prompt against the provider and return a normalised response.
- Return type:
- abstractmethod async arun(prompt, user_message, *, history=None, tools=None, temperature=0.0, max_tokens=4096, **kwargs)[source]
Async variant of
run().- Return type:
- class ractogateway.adapters.FinishReason(*values)[source]
-
Why the model stopped generating.
- STOP = 'stop'
- TOOL_CALL = 'tool_call'
- LENGTH = 'length'
- CONTENT_FILTER = 'content_filter'
- ERROR = 'error'
- class ractogateway.adapters.LLMResponse(**data)[source]
Bases:
BaseModelUnified, provider-agnostic response envelope.
Every adapter’s
run()method returns one of these, regardless of whether the underlying provider is OpenAI, Gemini, or Anthropic.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.
- tool_calls: list[ToolCallResult]
- finish_reason: FinishReason
- raw: 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.adapters.ToolCallResult(**data)[source]
Bases:
BaseModelA single tool/function call returned by the model.
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.
- id: str
- name: str
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].