feat: add LiteLLM as LLM provider#291
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
LLM_PROVIDER=litellmin.envlitellm.completion()withdrop_params=True, provider API keys read from standard environment variablesChanges
Backend/gpt.py-- add_litellm_generate_response()callinglitellm.completion()with timeout and bounds checking; route viaLLM_PROVIDERenv var with validation; add_list_litellm_models()for model discovery; existing Ollama code untouchedBackend/main.py-- update/api/modelsto use provider-awarelist_models()with correct error messages per provider.env.example-- documentLLM_PROVIDER,LITELLM_MODELsettingspyproject.toml-- addlitellm>=1.80.0,<1.87.0as optional dependency (pip install moneyprinter[litellm])Tests
Live E2E (Azure Foundry -> Claude Sonnet 4.6, through actual
gpt.generate_response()code path):Example usage
# .env LLM_PROVIDER=litellm LITELLM_MODEL=anthropic/claude-sonnet-4-20250514 ANTHROPIC_API_KEY=sk-ant-...Risk / Compatibility
LLM_PROVIDERdefaults to"ollama", preserving existing behavior; unknown values log a warning and fall back to Ollamalitellmis an optional dependency -- existing users without it are unaffected (lazy import inside_litellm_generate_response)drop_params=Trueensures unsupported params are silently dropped per providerlist_ollama_modelsremains as alias for backward compatibility