The
FallbackAdapter in LiveKit ensures high availability and reliability when working with multiple LLM (Large Language Model) providers by providing automatic failover capabilities. Here's how it works:
•
Automatic Failover: It tries the primary LLM first and switches to the next available LLM if the primary fails due to timeouts or errors. This continues until a successful response is received or all LLMs are tried.
•
Background Recovery: Failed LLMs are periodically checked in the background to see if they become available again. If they recover, an event is emitted to notify listeners.
•
Configurable Retry Policies: You can customize retry behavior, including timeouts, retry intervals, and the number of retries per LLM.
•
Availability Events: The adapter emits events whenever an LLM's availability status changes, allowing dynamic monitoring and adjustments.
For example, you can initialize the adapter with multiple LLMs and configure parameters like
attempt_timeout
and
max_retry_per_llm
. When a request is made, the adapter handles failover and recovery seamlessly.
If you'd like more details or need help implementing this, let me know!