Clients.AsyncFFLiteLLMClient
Async LiteLLM-backed AI client implementing AsyncFFAIClientBase contract.
Mirrors FFLiteLLMClient but uses litellm.acompletion() for async
I/O. Shares all non-I/O logic via BaseLiteLLMClient.
Async LiteLLM-backed AI client implementing AsyncFFAIClientBase contract.
Mirrors FFLiteLLMClient but uses litellm.acompletion() for async
I/O. Shares all non-I/O logic via BaseLiteLLMClient.
- class AsyncFFLiteLLMClient(model_string, config=None, *, api_key=None, api_base=None, api_version=None, system_instructions=None, temperature=None, max_tokens=None, fallbacks=None, retry_config=None, **kwargs)[source]
Bases:
BaseLiteLLMClient,AsyncFFAIClientBaseAsync LiteLLM-backed AI client implementing AsyncFFAIClientBase.
Key features: - Internal conversation history management - Clone pattern for parallel execution - Model string routing (e.g., “azure/mistral-small-2503”) - Retry and fallback support
- Parameters:
model_string (str) – LiteLLM model identifier.
config (dict[str, Any] | None) – Optional configuration dictionary.
api_key (str | None) – API key (overrides env var).
api_base (str | None) – API base URL (overrides env var).
system_instructions (str) – System prompt.
temperature (float) – Sampling temperature (0-2).
max_tokens (int) – Maximum tokens to generate.
fallbacks (list[str] | None) – List of fallback model strings.
api_version (str | None)
kwargs (Any)
- async generate_response(prompt, model=None, system_instructions=None, temperature=None, max_tokens=None, **kwargs)[source]
Generate a response from the model asynchronously.
Falls back to configured fallback models when the primary call fails.
- Parameters:
prompt (str) – User’s input text.
model (str | None) – Model identifier override (preserves provider prefix if set).
system_instructions (str | None) – System prompt override.
temperature (float | None) – Sampling temperature override.
max_tokens (int | None) – Maximum tokens to generate override.
**kwargs (Any) – Additional parameters forwarded to
litellm.acompletion().
- Returns:
The model’s response text.
- Raises:
ValueError – If the prompt is empty.
RuntimeError – If all models (primary + fallbacks) fail.
- Return type:
Classes
- class AsyncFFLiteLLMClient(model_string, config=None, *, api_key=None, api_base=None, api_version=None, system_instructions=None, temperature=None, max_tokens=None, fallbacks=None, retry_config=None, **kwargs)[source]
Bases:
BaseLiteLLMClient,AsyncFFAIClientBaseAsync LiteLLM-backed AI client implementing AsyncFFAIClientBase.
Key features: - Internal conversation history management - Clone pattern for parallel execution - Model string routing (e.g., “azure/mistral-small-2503”) - Retry and fallback support
- Parameters:
model_string (str) – LiteLLM model identifier.
config (dict[str, Any] | None) – Optional configuration dictionary.
api_key (str | None) – API key (overrides env var).
api_base (str | None) – API base URL (overrides env var).
system_instructions (str) – System prompt.
temperature (float) – Sampling temperature (0-2).
max_tokens (int) – Maximum tokens to generate.
fallbacks (list[str] | None) – List of fallback model strings.
api_version (str | None)
kwargs (Any)
- async generate_response(prompt, model=None, system_instructions=None, temperature=None, max_tokens=None, **kwargs)[source]
Generate a response from the model asynchronously.
Falls back to configured fallback models when the primary call fails.
- Parameters:
prompt (str) – User’s input text.
model (str | None) – Model identifier override (preserves provider prefix if set).
system_instructions (str | None) – System prompt override.
temperature (float | None) – Sampling temperature override.
max_tokens (int | None) – Maximum tokens to generate override.
**kwargs (Any) – Additional parameters forwarded to
litellm.acompletion().
- Returns:
The model’s response text.
- Raises:
ValueError – If the prompt is empty.
RuntimeError – If all models (primary + fallbacks) fail.
- Return type:
- async clone()[source]
Create a deep copy of this client with reset usage and empty history.
- Returns:
A new
AsyncFFLiteLLMClientwith identical configuration.- Return type:
- add_tool_result(tool_call_id, content)
Append a tool result message to the conversation history.
- clear_conversation()
Remove all messages from the conversation history.
- Return type:
None
- configure_retry(retry_config=None)
Configure retry behavior for this client.
- get_conversation_history()
Return a shallow copy of the conversation history.
- static get_default_retry_config()
Get default retry configuration from global config.
- property last_duration_ms: float | None
Wall-clock duration in ms of the most recent generate_response() call.
- property last_usage: TokenUsage | None
Token usage from the most recent generate_response() call.
- set_conversation_history(history)
Replace the conversation history with a new list of messages.