Skip to content

updated model configuration in routing.#20

Merged
kernelism merged 10 commits intomasterfrom
model-config-refactoring
May 22, 2025
Merged

updated model configuration in routing.#20
kernelism merged 10 commits intomasterfrom
model-config-refactoring

Conversation

@kernelism
Copy link
Collaborator

@kernelism kernelism commented May 20, 2025

updated model configuration in routing. added the option to include model lists in .env and updated .env.example as well.
Included a fallback function with our default set of models. The need for this is debatable.

…odel lists in .env and updated .env.example as well.
@kernelism kernelism changed the title updated model configuration in routing. added the option to include m… updated model configuration in routing. May 20, 2025

# The model_id for LiteLLMRouterModel is the default model group the router will target.
# Our _get_target_model() will override this per call via the 'model' param in generate().
default_model_group = os.getenv("LITELLM_DEFAULT_MODEL_GROUP", "gpt-4")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's not assume a model group, this will fail later somewhere, for new self-hosted users right?

.env.example Outdated
Comment on lines +2 to +6
LITELLM_MODEL_1_JSON='{"model_name": "gpt-4", "litellm_params": {"model": "azure/gpt-4", "base_url": "https://your-endpoint.openai.azure.com", "api_key": "your-key", "api_version": "2023-05-15", "weight": 5}}'
LITELLM_MODEL_2_JSON='{"model_name": "gpt-4", "litellm_params": {"model": "azure/gpt-4-1106-preview", "base_url": "https://your-endpoint-2.openai.azure.com", "api_key": "your-key-2", "api_version": "2023-05-15", "weight": 3}}'
LITELLM_MODEL_3_JSON='{"model_name": "gpt-4-reasoning", "litellm_params": {"model": "azure/gpt-4o-mini", "api_base": "https://your-endpoint-3.openai.azure.com", "api_key": "your-key-3", "api_version": "2023-05-15", "weight": 1}}'

LITELLM_ROUTER_CONFIG_JSON='{"routing_strategy": "simple-shuffle", "fallbacks": [{"gpt-4": ["gpt-4-reasoning"]}], "default_litellm_params": {"drop_params": true}}'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, I'd rather define these in a toml or json file (prefereably toml). And make the code read from that file. Also add the same file to .gitignore so that it's not checked in. And add an env variable called LITELLM_CONFIG_PATH in case I want to override the default path to the file.

@gautamp8
Copy link
Collaborator

LGTM

Comment on lines +88 to +92
model_config = {
"model_name": entry.get("model_name"),
"litellm_params": entry.get("litellm_params", {}),
"weight": entry.get("weight", 1)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's make this a pydantic schema so that validation happens on it's own

Comment on lines +153 to +156
return {
"routing_strategy": "simple-shuffle",
"fallbacks": [{"gpt-4": ["gpt-4-reasoning"]}],
"default_litellm_params": {"drop_params": True},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's also make this a pydantic schema

@kernelism kernelism merged commit 8f5df2a into master May 22, 2025
1 check failed
@BhaveshKukreja29 BhaveshKukreja29 deleted the model-config-refactoring branch January 12, 2026 05:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants