agent_framework.drivers#
Module API#
Provider-specific model driver implementations.
- class agent_framework.drivers.DialChatCompletionsDriver(base_url, deployment='', api_version='2024-10-21', api_key='', custom_fields=None, retry_without_response_format=True, retry_on_rate_limit=True, rate_limit_max_attempts=3, rate_limit_initial_delay_seconds=5.0, rate_limit_max_delay_seconds=60.0, timeout=120.0, on_request_trace=None, on_response_trace=None, _client=None, _httpx_loop=None, _fallback_state=<factory>)[source]#
Bases:
ModelDriverBase,_FallbackMixinAsync driver for DIAL (OpenAI-compatible chat completions).
Uses
aidial_sdk.chat_completion.requesttypes for well-typed request construction. Uses agent_framework’s standardProviderRequestTrace/ProviderResponseTracecallbacks for tracing — dial-agent should adopt this trace mechanism rather than its custom logging hooks.- Parameters:
base_url (str)
deployment (str)
api_version (str)
api_key (str)
custom_fields (dict[str, Any] | None)
retry_without_response_format (bool)
retry_on_rate_limit (bool)
rate_limit_max_attempts (int)
rate_limit_initial_delay_seconds (float)
rate_limit_max_delay_seconds (float)
timeout (float)
on_request_trace (Any | None)
on_response_trace (Any | None)
_client (Any | None)
_httpx_loop (Any | None)
_fallback_state (dict[tuple[str, ...], int])
- base_url#
DIAL API base URL (e.g.
https://dial.example.com).- Type:
str
- deployment#
Optional default deployment name. Kept for backward compatibility and direct construction in tests. In normal use the active deployment is taken from the
model_namesargument passed todecide()on each call.- Type:
str
- api_version#
api-versionquery parameter (default"2024-10-21").- Type:
str
- api_key#
DIAL API key sent as the
Api-Keyheader.- Type:
str
- custom_fields#
Optional
custom_fieldsdict merged into the request body (DIAL-specific extensions).- Type:
dict[str, Any] | None
- retry_without_response_format#
If True (default), re-try once without
response_formatwhen DIAL returns HTTP 400.- Type:
bool
- timeout#
HTTP timeout in seconds (default 120).
- Type:
float
- on_request_trace#
Optional
ProviderRequestTracecallback.- Type:
Any | None
- on_response_trace#
Optional
ProviderResponseTracecallback.- Type:
Any | None
- _fallback_state#
Per-model-list fallback index map (managed by
_FallbackMixin). Callreset_model_fallback()to restart from the first model.- Type:
dict[tuple[str, …], int]
- base_url: str#
- deployment: str#
- api_version: str#
- api_key: str#
- custom_fields: dict[str, Any] | None#
- retry_without_response_format: bool#
- retry_on_rate_limit: bool#
- rate_limit_max_attempts: int#
- rate_limit_initial_delay_seconds: float#
- rate_limit_max_delay_seconds: float#
- timeout: float#
- on_request_trace: Any | None#
- on_response_trace: Any | None#
- capabilities: ClassVar[DriverCapabilities] = DriverCapabilities(is_async=True, supports_multimodal=True, supports_response_format=True, supports_tools=True, supports_streaming=False)#
- async decide(*, agent_id, provider_name, model_names, temperature, context)[source]#
Request a structured response from a DIAL deployment.
Tries each model in
model_namesin order, starting from the last known-good index. The active deployment name for each attempt is taken directly from the model list;self.deploymentis not used.- Parameters:
agent_id (str | None)
provider_name (str)
model_names (tuple[str, ...])
temperature (float)
context (ModelContext)
- Return type:
- class agent_framework.drivers.OpenAiModelDriver(api_key, on_request_trace=None, on_response_trace=None, _fallback_state=<factory>, _client=None)[source]#
Bases:
ModelDriverBase,_FallbackMixinOpenAI-backed model driver for the Responses API.
- Parameters:
api_key (str)
on_request_trace (Any | None)
on_response_trace (Any | None)
_fallback_state (dict[tuple[str, ...], int])
_client (Any)
- api_key: str#
- on_request_trace: Any | None#
- on_response_trace: Any | None#
- capabilities: ClassVar[DriverCapabilities] = DriverCapabilities(is_async=False, supports_multimodal=False, supports_response_format=True, supports_tools=False, supports_streaming=False)#
- decide(*, agent_id, provider_name, model_names, temperature, context)[source]#
Request a structured decision from the OpenAI Responses API.
- Parameters:
agent_id (str | None)
provider_name (str)
model_names (tuple[str, ...])
temperature (float)
context (ModelContext)
- Return type: