mirror of
https://github.com/openai/codex.git
synced 2026-09-16 12:13:30 +00:00
apply overrides to picker, add test for ModelInfo/ModelInfoPatch drift
This commit is contained in:
@@ -256,7 +256,7 @@ pub struct ModelInfo {
|
||||
|
||||
/// User-provided patch for overriding model metadata in local config.
|
||||
///
|
||||
/// Every field is optional so users can override only the parts they need.
|
||||
/// Every field is optional so users can override only the parts of [`ModelInfo`] they need.
|
||||
/// The target model slug is provided by the surrounding map key.
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, TS, JsonSchema)]
|
||||
#[serde(default)]
|
||||
@@ -283,6 +283,7 @@ pub struct ModelInfoPatch {
|
||||
pub effective_context_window_percent: Option<i64>,
|
||||
pub experimental_supported_tools: Option<Vec<String>>,
|
||||
pub input_modalities: Option<Vec<InputModality>>,
|
||||
pub prefer_websockets: Option<bool>,
|
||||
}
|
||||
|
||||
impl ModelInfo {
|
||||
@@ -514,6 +515,7 @@ fn nearest_effort(target: ReasoningEffort, supported: &[ReasoningEffort]) -> Rea
|
||||
mod tests {
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
fn test_model(spec: Option<ModelMessages>) -> ModelInfo {
|
||||
ModelInfo {
|
||||
@@ -697,4 +699,34 @@ mod tests {
|
||||
);
|
||||
assert_eq!(personality_variables.get_personality_message(None), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn model_info_patch_field_coverage_is_explicit() {
|
||||
fn schema_fields<T: JsonSchema>() -> BTreeSet<String> {
|
||||
let schema = schemars::schema_for!(T);
|
||||
let object = schema
|
||||
.schema
|
||||
.object
|
||||
.as_ref()
|
||||
.expect("expected object schema");
|
||||
object.properties.keys().cloned().collect()
|
||||
}
|
||||
|
||||
let model_info_fields = schema_fields::<ModelInfo>();
|
||||
let patch_fields = schema_fields::<ModelInfoPatch>();
|
||||
let intentionally_non_patchable: BTreeSet<String> =
|
||||
["slug".to_string()].into_iter().collect();
|
||||
let expected_patch_fields: BTreeSet<String> = model_info_fields
|
||||
.difference(&intentionally_non_patchable)
|
||||
.cloned()
|
||||
.collect();
|
||||
|
||||
assert_eq!(patch_fields, expected_patch_fields);
|
||||
for field in &intentionally_non_patchable {
|
||||
assert!(
|
||||
model_info_fields.contains(field),
|
||||
"intentionally_non_patchable contains unknown field: {field}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user