feat: add LiteLLM as AI gateway provider#269
Open
RheagalFire wants to merge 1 commit into
Open
Conversation
Signed-off-by: RheagalFire <arishalam121@gmail.com>
Collaborator
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: RheagalFire The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Collaborator
|
Welcome @RheagalFire! It looks like this is your first PR to zilliztech/deep-searcher 🎉 |
Author
|
/assign @zc277584121 |
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
through a single interface.
deepsearcher[litellm]), keeping the default install lightweight.Motivation
DeepSearcher already supports 18 LLM providers, each requiring a separate SDK and configuration. LiteLLM provides a unified gateway that routes to any provider using a single API,
reducing the need to maintain per-provider code. Users who already run a LiteLLM proxy get instant access to all their configured models.
Changes
deepsearcher/llm/litellm_llm.py- NewLiteLLMclass implementingBaseLLMdeepsearcher/embedding/litellm_embedding.py- NewLiteLLMEmbeddingclass implementingBaseEmbeddingdeepsearcher/llm/__init__.py- RegisteredLiteLLMproviderdeepsearcher/embedding/__init__.py- RegisteredLiteLLMEmbeddingproviderpyproject.toml- Addedlitellm>=1.80.0,<1.87.0as optional dependencydeepsearcher/config.yaml- Added commented configuration examplestests/llm/test_litellm.py- 10 unit tests for LLM providertests/embedding/test_litellm_embedding.py- 8 unit tests for embedding providerProof of work
Unit tests (18/18 passing):
tests/llm/test_litellm.py::TestLiteLLM::test_chat_multiple_messages PASSED
tests/llm/test_litellm.py::TestLiteLLM::test_chat_omits_credentials_when_not_set PASSED
tests/llm/test_litellm.py::TestLiteLLM::test_chat_single_message PASSED
tests/llm/test_litellm.py::TestLiteLLM::test_chat_with_api_key PASSED
tests/llm/test_litellm.py::TestLiteLLM::test_chat_with_error PASSED
tests/llm/test_litellm.py::TestLiteLLM::test_drop_params_always_true PASSED
tests/llm/test_litellm.py::TestLiteLLM::test_init_default PASSED
tests/llm/test_litellm.py::TestLiteLLM::test_init_with_api_key_from_env PASSED
tests/llm/test_litellm.py::TestLiteLLM::test_init_with_api_key_parameter PASSED
tests/llm/test_litellm.py::TestLiteLLM::test_init_with_custom_model PASSED
tests/embedding/test_litellm_embedding.py::TestLiteLLMEmbedding::test_dimension_property PASSED
tests/embedding/test_litellm_embedding.py::TestLiteLLMEmbedding::test_embed_documents PASSED
tests/embedding/test_litellm_embedding.py::TestLiteLLMEmbedding::test_embed_query PASSED
tests/embedding/test_litellm_embedding.py::TestLiteLLMEmbedding::test_embed_query_omits_credentials_when_not_set PASSED
tests/embedding/test_litellm_embedding.py::TestLiteLLMEmbedding::test_embed_query_with_credentials PASSED
tests/embedding/test_litellm_embedding.py::TestLiteLLMEmbedding::test_init_default PASSED
tests/embedding/test_litellm_embedding.py::TestLiteLLMEmbedding::test_init_with_env_vars PASSED
tests/embedding/test_litellm_embedding.py::TestLiteLLMEmbedding::test_init_with_parameters PASSED
18 passed
Lint:
ruff checkandruff format --checkboth pass clean.Implementation notes
drop_params=Trueis always set so provider-unsupported kwargs (e.g.,seed,frequency_penaltyon Anthropic) are silently dropped instead of causing errors.api_keyandapi_baseare only forwarded when set. When omitted, LiteLLM reads provider-specific environment variables automatically (e.g.,ANTHROPIC_API_KEY,OPENAI_API_KEY).litellmis lazy-imported inside method bodies so users who don't install it are unaffected.Risk / Compatibility
litellmis an optional extra - base install unaffected.Example usage