Replace hand-rolled provider functions with LiteLLM - #118
Open
RheagalFire wants to merge 2 commits into
Open
RheagalFire wants to merge 2 commits into
RheagalFire wants to merge 2 commits into
Conversation
Swap four separate OpenAI/Anthropic/DeepSeek/Grok functions and three identical if/elif dispatcher chains for a single litellm.completion() call with automatic provider routing.
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.
Motivation
prompt_models.pycontains four separate provider functions (prompt_chatgpt,prompt_claude,prompt_deepseek,prompt_grok) plus three identical if/elif dispatcher chains that route by model name substring. Adding a new provider means writing a new function, updating all three dispatchers, and adding a new SDK dependency.LiteLLM is an open-source AI gateway that provides a unified
completion()interface for 100+ LLM providers using the OpenAI format. Replacing the hand-rolled functions with a singlelitellm.completion()call:prompt_models.pyfrom 130 lines to 52MODELSinworkflow.py)openai+anthropicSDK dependencies with one dependency (litellm)Changes
prompt_orchestration/prompt_models.pyprompt_model()usinglitellm.completion()requirements.txtopenai==2.32.0andanthropic==0.107.1, addedlitellm>=1.80.0,<1.87.0(litellm installs both as transitive deps)How provider routing works
LiteLLM routes based on model name prefixes (e.g.,
anthropic/claude-sonnet-4-6,bedrock/anthropic.claude-3-sonnet,vertex_ai/gemini-2.0-flash). A small_to_litellm_model()helper maps the repo's existing model names (deepseek-*,grok-*) to their LiteLLM prefix format so current configs keep working. Any of LiteLLM's 100+ supported providers can be used by passing the model name in LiteLLM format directly.Env var compatibility
LiteLLM reads the standard env vars automatically:
OPENAI_API_KEYDEEPSEEK_API_KEYANTHROPIC_API_KEYXAI_API_KEYFor backward compatibility, if
CLAUDE_API_KEYis set butANTHROPIC_API_KEYis not, the module bridges them automatically.Adding a new provider
Just add the model name in LiteLLM format to the
MODELSlist:No new functions, no new SDK dependencies, no dispatcher changes.
Tested
Module import chain verified: