feat: add LiteLLM as AI gateway provider#264
Open
RheagalFire wants to merge 2 commits into
Open
Conversation
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds LiteLLM as an optional AI gateway SDK for both LLM chat and embeddings. Users set
EVEROS_LLM__PROVIDER=litellmand a provider-prefixed model id (e.g.anthropic/claude-sonnet-4-6) to access 100+ LLM providers through a unified Python SDK.drop_params=Trueis always passed so provider-unsupported kwargs (seed,frequency_penalty,strict) are silently dropped.Follows the existing
RerankSettingsdispatch pattern: addsprovider: Literal["openai", "litellm"]toLLMSettingsandEmbeddingSettings. Default is"openai"- existing behavior is completely unchanged.Area
Verification
LLM provider tests (11 tests):
Embedding provider tests (9 tests):
Factory dispatch tests (10 tests):
Live E2E against Azure Foundry (Claude via LiteLLM SDK):
Checklist
main..envfiles, dependency folders, or generated output.Notes for Reviewers
Additive only. The default
provider="openai"path is untouched - no existing code paths change.litellmis lazy-imported inside function bodies so users who never install it see no difference.Bug fixes applied during review:
item["embedding"]->item.embeddingin embedding provider (attribute access matching OpenAI sibling)completion.choiceslist (was IndexError)litellm.exceptions.*tolitellm.*(catcheslitellm.Timeout,litellm.BudgetExceededError)api_keyforwarding: truthiness check ->is not None(empty string now correctly sent rather than silently falling back to env vars)Files created:
src/everos/component/llm/litellm_provider.py-LiteLLMProvider(async, satisfiesLLMClientprotocol)src/everos/component/embedding/litellm_provider.py-LiteLLMEmbeddingProvider(async, satisfiesEmbeddingProviderprotocol, with batching + semaphore concurrency matching the OpenAI sibling)tests/unit/test_component/test_llm/test_litellm_provider.py- 11 teststests/unit/test_component/test_embedding/test_litellm_provider.py- 9 testsFiles modified:
src/everos/config/settings.py- addedproviderfield toLLMSettingsandEmbeddingSettingssrc/everos/component/llm/factory.py- dispatch onsettings.providersrc/everos/component/llm/client.py- singleton accessor routes through factory whenprovider="litellm"src/everos/component/embedding/factory.py- dispatch onsettings.providersrc/everos/component/{llm,embedding}/__init__.py- re-export new classespyproject.toml-litellm>=1.80.0,<2.0under[project.optional-dependencies].litellmtests/unit/test_component/test_llm/test_factory.py- 3 new litellm dispatch teststests/unit/test_component/test_embedding/test_factory.py- 3 new litellm dispatch testsUsage:
Or via env vars:
EVEROS_LLM__PROVIDER=litellm EVEROS_LLM__MODEL=anthropic/claude-sonnet-4-6 # litellm reads ANTHROPIC_API_KEY from env automaticallyBy submitting this pull request, I agree that my contribution is licensed under
the Apache License 2.0.