mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-11 11:49:50 +08:00
migrate ai format conversion to responses adapters
This commit is contained in:
@@ -19,7 +19,7 @@ use serde_json::json;
|
||||
|
||||
use crate::build_models_fetch_url;
|
||||
|
||||
const OPENAI_CLI_USER_AGENT: &str = "openai-codex/1.0";
|
||||
const OPENAI_RESPONSES_USER_AGENT: &str = "openai-codex/1.0";
|
||||
const CLAUDE_CLI_USER_AGENT: &str = "claude-code/1.0.1";
|
||||
const GEMINI_CLI_USER_AGENT: &str = "GeminiCLI/0.1.5 (Windows; AMD64)";
|
||||
const CLAUDE_VERSION_HEADER: &str = "2023-06-01";
|
||||
@@ -383,8 +383,11 @@ fn apply_fetch_header_rules(
|
||||
fn standard_models_fetch_headers(api_format: &str) -> BTreeMap<String, String> {
|
||||
let api_format = api_format.trim().to_ascii_lowercase();
|
||||
match api_format.as_str() {
|
||||
"openai:cli" | "openai:compact" => {
|
||||
BTreeMap::from([("user-agent".to_string(), OPENAI_CLI_USER_AGENT.to_string())])
|
||||
"openai:responses" | "openai:responses:compact" | "openai:cli" | "openai:compact" => {
|
||||
BTreeMap::from([(
|
||||
"user-agent".to_string(),
|
||||
OPENAI_RESPONSES_USER_AGENT.to_string(),
|
||||
)])
|
||||
}
|
||||
"claude:chat" => BTreeMap::from([(
|
||||
"anthropic-version".to_string(),
|
||||
@@ -577,12 +580,12 @@ mod tests {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn builds_openai_cli_models_fetch_plan_with_cli_user_agent() {
|
||||
async fn builds_openai_responses_models_fetch_plan_with_codex_user_agent() {
|
||||
let runtime = TestRuntime {
|
||||
oauth_auth: None,
|
||||
proxy: None,
|
||||
};
|
||||
let mut transport = sample_transport("openai", "openai:cli", "api_key");
|
||||
let mut transport = sample_transport("openai", "openai:responses", "api_key");
|
||||
transport.key.decrypted_auth_config = None;
|
||||
let plan = build_models_fetch_execution_plan(&runtime, &transport)
|
||||
.await
|
||||
@@ -600,12 +603,12 @@ mod tests {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn builds_openai_compact_models_fetch_plan_with_bearer_authorization() {
|
||||
async fn builds_openai_responses_compact_models_fetch_plan_with_bearer_authorization() {
|
||||
let runtime = TestRuntime {
|
||||
oauth_auth: None,
|
||||
proxy: None,
|
||||
};
|
||||
let mut transport = sample_transport("openai", "openai:compact", "api_key");
|
||||
let mut transport = sample_transport("openai", "openai:responses:compact", "api_key");
|
||||
transport.key.decrypted_auth_config = None;
|
||||
let plan = build_models_fetch_execution_plan(&runtime, &transport)
|
||||
.await
|
||||
|
||||
Reference in New Issue
Block a user