-
Notifications
You must be signed in to change notification settings - Fork 210
feat: Implemented FallbackAdapter for LLM #916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: c9736b2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 15 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
toubatbrian
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tested fallback yet? Could you add a simple example ts file under examples showcasing the basic usage of this class. Thanks!
|
I won’t be able to do this today. I’ll test the fallback and add a simple example TS file under examples tomorrow. |
|
Thanks @KrishnaShuk! |
|
I need to test this further. I’ll provide an update shortly. |
Description
#868
This PR implements the
FallbackAdapterfor LLMs, bringing feature parity with the Python SDK. This component allows agents to automatically switch to backup LLM providers if the primary provider fails, times out, or becomes unavailable, ensuring high availability for production agents.Python(agents) SDK code for fallback adapter: https://github.com/livekit/agents/blob/main/livekit-agents/livekit/agents/llm/fallback_adapter.py
Changes Made
packages/agents/src/llm/FallbackAdapter.tsimplementing theFallbackAdapterandFallbackLLMStreamclasses.ChatContextto verify when a failed provider has recovered (instead of a simple timer).llm_availability_changedevents when providers go down or recover.retryOnChunkSentto prevent the agent from repeating partial sentences if a stream fails mid-generation.packages/agents/src/llm/index.ts.Pre-Review Checklist
Testing
restaurant_agent.tsandrealtime_agent.tswork properly (This change is additive/opt-in and does not affect existing agents unless configured to use the adapter)