Skip to content

feat: support user-defined model configuration#259

Merged
Syspretor merged 3 commits intosgl-project:mainfrom
diw-zw:model-config
Apr 10, 2026
Merged

feat: support user-defined model configuration#259
Syspretor merged 3 commits intosgl-project:mainfrom
diw-zw:model-config

Conversation

@diw-zw
Copy link
Copy Markdown
Collaborator

@diw-zw diw-zw commented Apr 7, 2026

Support User-Defined Model Configuration

Summary

Add support for loading user-defined model configurations from local directory, merging with built-in models. User models take precedence.

Additionally, fix incorrect examples for the llm generate command found in the documentation.

Changes

  1. Model Loading Mechanism

    • Default path: ~/.rbg/models/
    • Custom path via RBG_MODEL_CONFIG environment variable
    • Supports .yaml and .yml files
  2. Duplicate Detection

    • Warns when same model ID has multiple definitions
    • Aggregates all sources for easier debugging
  3. New Constants/Functions

    • DefaultModelConfigDir, EnvModelConfigPath
    • GetModelConfigDir()

Environment Variables

Variable Purpose Default
RBG_CONFIG CLI config file ~/.rbg/config
RBG_MODEL_CONFIG Model config directory ~/.rbg/models

Files Changed

  • cmd/cli/cmd/llm/run/model_config.go - New loading logic
  • cmd/cli/cmd/llm/run/model_config_test.go - Unit tests (7 cases)
  • cmd/cli/config/config.go - New constants/functions
  • cmd/cli/cmd/llm/run.go - Switch to new loader
  • cmd/cli/README.md, doc/features/kubectl-rbg-llm-generate.md - Docs update

@diw-zw diw-zw requested review from bcfre and cheyang and removed request for bcfre April 7, 2026 11:44
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the ability to load user-defined model configurations from a local directory, merging them with built-in models and allowing user overrides. It also updates documentation and CLI examples to reflect a new model naming convention. The review feedback suggests addressing non-deterministic map iteration in conflict warnings to ensure consistent CLI output, explicitly verifying that the model configuration path is a directory, and making the YAML file extension check case-insensitive for better robustness.

Comment thread cmd/cli/cmd/llm/run/model_config.go Outdated
Comment thread cmd/cli/cmd/llm/run/model_config.go Outdated
Comment thread cmd/cli/cmd/llm/run/model_config.go
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds support in the CLI for loading user-provided model configuration YAMLs from a local directory and merging them with the embedded built-in model configs (user definitions take precedence). Also updates documentation examples for kubectl rbg llm generate.

Changes:

  • Add model config directory discovery via RBG_MODEL_CONFIG (default ~/.rbg/models) and merge user configs ahead of built-ins.
  • Add duplicate model-ID detection with aggregated warning output.
  • Update llm run to use the merged model loader and add unit tests for user-model loading scenarios.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
cmd/cli/cmd/llm/run/model_config.go Implements merged model loading (user dir + embedded), plus conflict detection/warnings.
cmd/cli/cmd/llm/run/model_config_test.go Adds unit tests covering user model directory loading, overrides, duplicates, invalid files.
cmd/cli/config/config.go Introduces constants and GetModelConfigDir() to locate the user model config directory.
cmd/cli/cmd/llm/run.go Switches resolution logic to use LoadAllModels() instead of built-ins only.
cmd/cli/README.md Updates generate examples (but currently has filename/PVC mismatches vs actual CLI output).
doc/features/kubectl-rbg-llm-generate.md Updates generate docs/examples (but currently has filename/PVC + troubleshooting pattern mismatches vs actual CLI behavior).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/cli/cmd/llm/run/model_config.go
Comment thread cmd/cli/cmd/llm/run/model_config.go
Comment thread doc/features/kubectl-rbg-llm-generate.md
Comment thread doc/features/kubectl-rbg-llm-generate.md
Comment thread doc/features/kubectl-rbg-llm-generate.md
Comment thread doc/features/kubectl-rbg-llm-generate.md Outdated
Comment thread doc/features/kubectl-rbg-llm-generate.md
Comment thread cmd/cli/README.md Outdated
Comment thread cmd/cli/README.md Outdated
Comment thread doc/features/kubectl-rbg-llm-generate.md Outdated
Comment thread cmd/cli/cmd/llm/run/model_config.go
@diw-zw diw-zw force-pushed the model-config branch 2 times, most recently from 021eb52 to 4f6c835 Compare April 9, 2026 05:37
@cheyang cheyang requested a review from Copilot April 9, 2026 07:33
Copy link
Copy Markdown
Collaborator

@cheyang cheyang left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/cli/cmd/llm/run/model_config.go
Copy link
Copy Markdown
Collaborator

@Syspretor Syspretor left a comment

Choose a reason for hiding this comment

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

/lgtm

@Syspretor Syspretor merged commit 175c1b9 into sgl-project:main Apr 10, 2026
9 checks passed
@diw-zw diw-zw deleted the model-config branch April 30, 2026 08:44
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.

4 participants