Remove LiteLLM, replace with OpenAI + Anthropic SDKs#14
Merged
Conversation
LiteLLM had a significant security vulnerability. This replaces it with direct SDK usage routed through a new provider routing layer. - Add src/utils/provider_routing.py for model prefix → SDK target resolution - Migrate src/utils/llm.py: replace instructor.from_litellm with instructor.from_openai / from_anthropic based on model prefix - Unify cloud_generation/local_generation into shared _structured_generation (eliminates ~200 lines of duplicated retry/recovery logic) - Migrate cloud embeddings from litellm.embedding to OpenAI SDK - Remove dead code: get_llm_callbacks, BRAINTRUST_PROJECT_ID, get_ollama_model_name, OLLAMA_API_KEY, disable_llm_callbacks - Bump instructor>=1.14 (adds from_anthropic), add openai>=1.0, add anthropic as optional extra - Bump extraction cache version to v2 (transport change) - Update docs: README, CLAUDE.md, AGENTS.md
Ruff 0.15 (local) and 0.9 (CI lockfile) disagree on import grouping for this file. Restore the main-branch version to avoid CI lint failure.
The unpinned "ruff" dep resolved to 0.9.6 in CI but 0.15.7 locally, causing import sorting disagreements. Pin to >=0.15 so both environments use the same rules.
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
litellmdependency due to recent security vulnerability, replacing with direct SDK usagesrc/utils/provider_routing.py) that resolves model prefixes (gemini/,openai/,anthropic/,ollama/,openrouter/) to the correct SDK + endpointinstructor.from_litellm→instructor.from_openai/instructor.from_anthropicbased on model prefixcloud_generation/local_generationinto shared_structured_generation(), eliminating ~200 lines of duplicated retry/recovery logic and fixing a latent Anthropic guard buglitellm.embedding()to OpenAI SDKembeddings.create()get_llm_callbacks,BRAINTRUST_PROJECT_ID,get_ollama_model_name,OLLAMA_API_KEY,disable_llm_callbacksinstructor>=1.14, addopenai>=1.0, addanthropicas optional extra (pip install hinbox[anthropic])Supported model prefixes
gemini/gemini/gemini-2.0-flashopenai/openai/gpt-4oanthropic/anthropic/claude-sonnet-4-20250514ollama/ollama/qwen2.5:32bopenrouter/openrouter/anthropic/claude-3.5-sonnetTest plan
just cipasses)just process)just process --local)