mirror of
https://github.com/openai/codex.git
synced 2026-11-02 19:43:24 +00:00
feat(core): support custom model aliases in config.toml
Preserve custom model alias support on the current origin/main base and collapse the branch back to a single commit for easier future restacks.
This commit is contained in:
@@ -243,6 +243,11 @@ const fn default_effective_context_window_percent() -> i64 {
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, TS, JsonSchema)]
|
||||
pub struct ModelInfo {
|
||||
pub slug: String,
|
||||
/// Provider-facing model slug to send on API requests.
|
||||
///
|
||||
/// When unset, `slug` is used.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub request_model: Option<String>,
|
||||
pub display_name: String,
|
||||
pub description: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
@@ -294,6 +299,10 @@ pub struct ModelInfo {
|
||||
}
|
||||
|
||||
impl ModelInfo {
|
||||
pub fn request_model_slug(&self) -> &str {
|
||||
self.request_model.as_deref().unwrap_or(self.slug.as_str())
|
||||
}
|
||||
|
||||
pub fn auto_compact_token_limit(&self) -> Option<i64> {
|
||||
let context_limit = self
|
||||
.context_window
|
||||
@@ -519,6 +528,7 @@ mod tests {
|
||||
fn test_model(spec: Option<ModelMessages>) -> ModelInfo {
|
||||
ModelInfo {
|
||||
slug: "test-model".to_string(),
|
||||
request_model: None,
|
||||
display_name: "Test Model".to_string(),
|
||||
description: None,
|
||||
default_reasoning_level: None,
|
||||
|
||||
Reference in New Issue
Block a user