feat: add LiteLLM as AI gateway provider#502
Open
RheagalFire wants to merge 1 commit into
Open
Conversation
Author
Contributor
|
Hi @RheagalFire, I'm not involved in maintaining this library anymore, so please refrain from further pings 🙏 |
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.
Description
Adds LiteLLM as a new REST backend for spacy-llm, giving users access to 100+ LLM providers (OpenAI, Anthropic, Azure, Bedrock, Vertex AI, Groq, Ollama, etc.) through the LiteLLM Python SDK.
LiteLLM is added as a new provider under
spacy_llm/models/rest/litellm/, following the exact same pattern as the existing OpenAI, Anthropic, and Cohere providers. It registers asspacy.LiteLLM.v1in the model registry.Files added:
spacy_llm/models/rest/litellm/model.py--LiteLLMclass extendingREST, useslitellm.completion()withdrop_params=Truespacy_llm/models/rest/litellm/registry.py--@registry.llm_models("spacy.LiteLLM.v1")registrationspacy_llm/models/rest/litellm/__init__.py-- exportsFiles modified:
spacy_llm/models/rest/__init__.py-- registered litellm moduleLive E2E (Anthropic Claude Sonnet via Azure Foundry):
Example usage:
Config-based (spacy pipeline):
Python:
Model names use the litellm
provider/model-nameformat (e.g.anthropic/claude-haiku-4-5,openai/gpt-4o,bedrock/anthropic.claude-3-haiku).Corresponding documentation PR
N/A
Types of change
New feature -- adds a new LLM provider backend.
Checklist
testsandusage_examples/tests, and all new and existing tests passed. This includespytestran with--external)pytestran with--gpu)