feat: add litellm provider#431
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.
📝 Pull Request Summary
Add LiteLLM as a first-class AI gateway provider with both native SDK and HTTP proxy support, enabling access to 100+ LLM providers via
pip install memu-py[litellm].✅ What does this PR do?
LiteLLMSDKClientthat useslitellm.acompletion()andlitellm.aembedding()directly (no proxy server needed)LiteLLMBackendfor users who prefer the HTTP proxy path (client_backend="httpx")litellmas a newclient_backendoption alongsidesdk,httpx, andlazyllm_backendlitellm>=1.80.0,<1.87.0as an optional dependencybase_url=http://localhost:4000,api_key=LITELLM_API_KEY, auto-selectslitellmclient backendNew files:
src/memu/llm/litellm_sdk.py- SDK client withdrop_params=Truefor cross-provider compatibilitysrc/memu/llm/backends/litellm.py- HTTP proxy backend (inheritsOpenAILLMBackend)tests/llm/test_litellm_provider.py- 11 unit testsModified files:
src/memu/app/service.py- registeredlitellmclient backendsrc/memu/app/settings.py- provider defaultssrc/memu/llm/backends/__init__.py- registered exportsrc/memu/llm/http_client.py- registered inLLM_BACKENDSand embedding backendspyproject.toml- optional dependency🤔 Why is this change needed?
LiteLLM provides a unified Python SDK for 100+ LLM providers (Anthropic, Azure, Bedrock, Vertex, Groq, Ollama, etc.). Adding it as a native client backend lets users access any supported provider without running a proxy or waiting for per-provider backends to be added.
🔍 Type of Change
✅ PR Quality Checklist
📌 Optional
Live E2E (LiteLLM SDK, no proxy, Azure AI Foundry -> Claude Sonnet):
Unit tests (11/11 pass):
Lint:
ruff check+ruff format --check- clean.Example usage
SDK backend (recommended):
HTTP proxy backend: