This repository was archived by the owner on Aug 18, 2026. It is now read-only.
feat: add /model slash command to switch named models from config.toml - #33
Merged
Conversation
…pport Add LlmModel, a named model pairing a config.toml section name with an LlmConfig. Each [[model.<name>]] section accepts base_url, model, optional api_key, optional env_key (environment variable holding the API key), and optional api_mode. Models are returned in lexicographic name order; duplicate sections, empty or whitespace names, missing required fields, and invalid env_key values are rejected. The legacy [llm] section and SUI_LLM_* environment variables remain supported unchanged.
Extend the slash suggestion panel with switchable model candidates: typing /model (or /model <prefix>) lists the models attached via App::with_models, with the active one marked; Up/Down/Ctrl-N/Ctrl-P selects and Enter switches. /model <name> switches by name, and a bare /model cycles or explains how to configure named models when none are set. Tab cycles model candidates without replacing the command text. App gains models + active_model state; with_models activates the first model, and with_llm clears switchable state so single-client mode stays consistent.
At startup, load [[model.<name>]] sections via LlmModel::from_config and wire them into App::with_models so /model switching works out of the box. When no named models are configured, fall back to the legacy LlmClient::from_config_or_env path so existing [llm] / SUI_LLM_* setups are unchanged.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
What
Adds a
/modelslash command that switches between models configured inconfig.tomlas named[[model."<name>"]]sections:Each section accepts
base_url,model, and optionallyapi_key/env_key/api_mode.env_keyreads the API key from the named environment variable, keeping secrets out of the config file.Usage
/model(or/model <prefix>) — the suggestion panel lists the configured models, with the active one marked; Up/Down/Ctrl-N/Ctrl-P highlights, Enter switches./model <name>switches directly by name./modelwith no models configured explains how to add sections.Why
The single flat
[llm]section could only configure one endpoint. Named sections make local (Ollama/vLLM) and cloud models switchable at runtime without editing config, mirroring pi's/modelselector in this fork's simpler suggestion-panel architecture.How it was validated
cargo test --workspace— all crates pass (107 sui-app, 56 sui-llm tests incl. new model parsing/env_key/reject cases)cargo clippy --workspace --all-targets -- -D warnings— cleancargo fmt --all --check— cleanslash_model_*testsLegacy behavior is preserved: when no
[[model."..."]]sections exist, startup falls back to the existingLlmClient::from_config_or_env([llm]section orSUI_LLM_*env vars) path.Commits
feat(sui-llm): parse named [[model."<name>"]] configs with env_key supportfeat(sui-app): add /model slash command to switch named modelsfeat(sui): prefer named models from config.toml over legacy [llm]