Skip to content

refactor: centralize model parameters into JSON config (model_specs)#2176

Open
Haixing-Hu wants to merge 4 commits intolbjlaq:mainfrom
Haixing-Hu:refactor/model-config-json
Open

refactor: centralize model parameters into JSON config (model_specs)#2176
Haixing-Hu wants to merge 4 commits intolbjlaq:mainfrom
Haixing-Hu:refactor/model-config-json

Conversation

@Haixing-Hu
Copy link

refactor: centralize model parameters into JSON config (model_specs)

Replace hardcoded model-specific parameters (maxOutputTokens, thinkingBudget
caps, overhead values, model aliases) with a centralized JSON config file
(resources/model_specs.json) and a Rust registry module (proxy/model_specs.rs).

New files:
- resources/model_specs.json: all model parameters in one place
- src/proxy/model_specs.rs: config loading, lookup (with prefix matching),
  and convenience functions (cap_max_output_tokens, cap_thinking_budget, etc.)

Refactored files:
- common_utils.rs: model alias resolution via model_specs::resolve_alias()
- gemini/wrapper.rs: default thinking budget, budget capping, maxOutputTokens
  cap, adaptive max tokens, thinking overhead — all from config
- openai/request.rs: default budget, budget caps, overhead values from config
- claude/request.rs: default budget, budget caps, opus fixed values,
  maxOutputTokens safe limit, overhead values — all from config

Benefits:
- Adding new models or adjusting limits requires only editing model_specs.json
- No more scattered magic numbers (24576, 65536, 131072, 16000, etc.)
- Consistent behavior across all three protocol mappers

Replace hardcoded model-specific parameters (maxOutputTokens, thinkingBudget
caps, overhead values, model aliases) with a centralized JSON config file
(resources/model_specs.json) and a Rust registry module (proxy/model_specs.rs).

New files:
- resources/model_specs.json: all model parameters in one place
- src/proxy/model_specs.rs: config loading, lookup (with prefix matching),
  and convenience functions (cap_max_output_tokens, cap_thinking_budget, etc.)

Refactored files:
- common_utils.rs: model alias resolution via model_specs::resolve_alias()
- gemini/wrapper.rs: default thinking budget, budget capping, maxOutputTokens
  cap, adaptive max tokens, thinking overhead — all from config
- openai/request.rs: default budget, budget caps, overhead values from config
- claude/request.rs: default budget, budget caps, opus fixed values,
  maxOutputTokens safe limit, overhead values — all from config

Benefits:
- Adding new models or adjusting limits requires only editing model_specs.json
- No more scattered magic numbers (24576, 65536, 131072, 16000, etc.)
- Consistent behavior across all three protocol mappers
@Haixing-Hu Haixing-Hu changed the title Refactor/model config json refactor: centralize model parameters into JSON config (model_specs) Feb 28, 2026
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.

1 participant