feat: add model name configuration support for Codex and fix Gemini model handling
- Add visual model name input field for Codex providers - Add model name extraction and update utilities in providerConfigUtils - Implement model name state management in useCodexConfigState hook - Add conditional model field rendering in CodexFormFields (non-official only) - Integrate model name sync with TOML config in ProviderForm - Fix Gemini deeplink model injection bug - Correct environment variable name from GOOGLE_GEMINI_MODEL to GEMINI_MODEL - Add test cases for Gemini model injection (with/without model) - All tests passing (9/9) - Fix Gemini model field binding in edit mode - Add geminiModel state to useGeminiConfigState hook - Extract model value during initialization and reset - Sync model field with geminiEnv state to prevent data loss on submit - Fix missing model value display when editing Gemini providers Changes: - 6 files changed, 245 insertions(+), 13 deletions(-)
This commit is contained in:
@@ -302,7 +302,7 @@ requires_openai_auth = true
|
||||
|
||||
// Add model if provided
|
||||
if let Some(model) = &request.model {
|
||||
env.insert("GOOGLE_GEMINI_MODEL".to_string(), json!(model));
|
||||
env.insert("GEMINI_MODEL".to_string(), json!(model));
|
||||
}
|
||||
|
||||
json!({ "env": env })
|
||||
@@ -400,4 +400,58 @@ mod tests {
|
||||
.to_string()
|
||||
.contains("must be http or https"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_build_gemini_provider_with_model() {
|
||||
let request = DeepLinkImportRequest {
|
||||
version: "v1".to_string(),
|
||||
resource: "provider".to_string(),
|
||||
app: "gemini".to_string(),
|
||||
name: "Test Gemini".to_string(),
|
||||
homepage: "https://example.com".to_string(),
|
||||
endpoint: "https://api.example.com".to_string(),
|
||||
api_key: "test-api-key".to_string(),
|
||||
model: Some("gemini-2.0-flash".to_string()),
|
||||
notes: None,
|
||||
};
|
||||
|
||||
let provider = build_provider_from_request(&AppType::Gemini, &request).unwrap();
|
||||
|
||||
// Verify provider basic info
|
||||
assert_eq!(provider.name, "Test Gemini");
|
||||
assert_eq!(
|
||||
provider.website_url,
|
||||
Some("https://example.com".to_string())
|
||||
);
|
||||
|
||||
// Verify settings_config structure
|
||||
let env = provider.settings_config["env"].as_object().unwrap();
|
||||
assert_eq!(env["GEMINI_API_KEY"], "test-api-key");
|
||||
assert_eq!(env["GOOGLE_GEMINI_BASE_URL"], "https://api.example.com");
|
||||
assert_eq!(env["GEMINI_MODEL"], "gemini-2.0-flash");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_build_gemini_provider_without_model() {
|
||||
let request = DeepLinkImportRequest {
|
||||
version: "v1".to_string(),
|
||||
resource: "provider".to_string(),
|
||||
app: "gemini".to_string(),
|
||||
name: "Test Gemini".to_string(),
|
||||
homepage: "https://example.com".to_string(),
|
||||
endpoint: "https://api.example.com".to_string(),
|
||||
api_key: "test-api-key".to_string(),
|
||||
model: None,
|
||||
notes: None,
|
||||
};
|
||||
|
||||
let provider = build_provider_from_request(&AppType::Gemini, &request).unwrap();
|
||||
|
||||
// Verify settings_config structure
|
||||
let env = provider.settings_config["env"].as_object().unwrap();
|
||||
assert_eq!(env["GEMINI_API_KEY"], "test-api-key");
|
||||
assert_eq!(env["GOOGLE_GEMINI_BASE_URL"], "https://api.example.com");
|
||||
// Model should not be present
|
||||
assert!(env.get("GEMINI_MODEL").is_none());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user