Repository navigation
Conversation
|
I'm concerned about the supply-chain boundary of this LiteLLM integration. The upstream incident report confirms compromised PyPI releases 1.82.7/1.82.8 in March 2026; those releases were removed. At reviewed head That upper bound permits later 1.x releases beyond a single tested version when dependencies are resolved afresh or upgraded. Please document tested versions, artifact verification, and whether installation of the SDK is opt-in. A disabled application feature cannot prevent an installed malicious Python-startup hook. This is one of 49 observed LiteLLM integration PRs from the same account, whose author acknowledged the cross-project effort. The pattern prompted this review; it does not establish malicious intent or connect the author to the incident. The consolidated questions and corrections are in YouDub #130; this PR's review snapshot preserves the revision and scope. |
Summary
Routes Cortex's LLM and embedding calls through the LiteLLM SDK instead of a hardcoded
anthropicclient and a hardcoded OpenAI embeddings path, so Cortex can run on any provider LiteLLM supports (Anthropic, OpenAI, Gemini, Bedrock, Vertex, Azure, Voyage, Cohere, or a LiteLLM proxy) via one interface.claude-opus-4-5) for generation, and the embedding provider selection (model2vec, openai, hash) is unchanged. Existing setups keep working with no config change.CORTEX_MODEL(for exampleopenai/gpt-4o,gemini/gemini-2.5-pro,bedrock/...); pick any embedding provider by settingCORTEX_EMBEDDING_PROVIDER=litellmand a provider prefixedCORTEX_EMBEDDING_MODEL(for examplevoyage/voyage-3,cohere/embed-english-v3.0,gemini/text-embedding-004). Credentials come from each provider's own env var.drop_params=Trueon every call, so one config works across providers that reject each other's params.Changes
ui.py:ask_cortex()now callslitellm.completion(...); model fromCORTEX_MODEL.ingest.py: extraction call now useslitellm.completion(...).backend/app/condense.py: condense call now useslitellm.completion(...)backend/app/extractor.py:_extract_with_claudenow useslitellm.completion(...)Embeddings
backend/app/embeddings.py: addslitellmas aCORTEX_EMBEDDING_PROVIDERoption backed bylitellm.embedding(new_litellm_embedding). model2vec, openai, and hash paths are untouched. Keeps the existing safety net: a dimension mismatch raises so retrieval degrades to the deterministic hash embedding (or fails in strict mode) rather than corrupting the vector index. OptionalCORTEX_LITELLM_BASE_URLandCORTEX_LITELLM_API_KEYpoint at a LiteLLM proxy.Packaging
requirements.txt,backend/requirements.txt: addlitellm>=1.89.0,<2.0.0Tests
1. Compile:
python -m py_compile ui.py ingest.py backend/app/condense.py backend/app/extractor.py backend/app/embeddings.pygives OK.2. Live call through a converted chat path (the exact
litellm.completionshape the four sites use, a system prompt plus a single user turn,drop_params=True), against a live model via a LiteLLM proxy:3. Embedding provider route (litellm stubbed, no network):
This confirms
CORTEX_EMBEDDING_PROVIDER=litellmroutes throughlitellm.embedding, forwards an output dimension only fortext-embedding-3models, and degrades to hash on a dimension mismatch so the index stays consistent.4. Pin resolves cleanly:
pip install "litellm>=1.89.0,<2.0.0"Risk and compatibility
ANTHROPIC_API_KEYandOPENAI_API_KEYsetups keep working.anthropicstays a dependency; the app no longer instantiates the Anthropic client directly.Example usage