mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 17:30:23 +08:00
fix(build): 修复网关构建失败并收口候选选择与 finalize 回归
- 补齐 DecisionTraceCandidate 新增字段,修复审计测试构造 - 修正 usage 内存仓库的 created_at_unix_ms 字段引用与秒/毫秒换算 - 将 build_minimal_candidate_selection 重构为输入对象,消除 clippy 参数过多问题 - 修复 admin global model created_at 旧字段残留引用 - 修复 openai:cli 与 openai:compact 同家族 finalize 在 needs_conversion=true 时的成功回落逻辑 - 清理 aether-gateway 中的 derive/default 与 needless borrow 等 clippy 问题
This commit is contained in:
@@ -441,8 +441,7 @@ fn maybe_build_openai_cli_same_family_sync_body(
|
||||
|
||||
if !is_openai_cli_family_api_format(&provider_api_format)
|
||||
|| !is_openai_cli_family_api_format(&client_api_format)
|
||||
|| provider_api_format != client_api_format
|
||||
|| needs_conversion
|
||||
|| (provider_api_format == client_api_format && needs_conversion)
|
||||
{
|
||||
return None;
|
||||
}
|
||||
@@ -488,8 +487,7 @@ fn maybe_build_openai_cli_same_family_stream_sync_body(
|
||||
|
||||
if !is_openai_cli_family_api_format(&provider_api_format)
|
||||
|| !is_openai_cli_family_api_format(&client_api_format)
|
||||
|| provider_api_format != client_api_format
|
||||
|| needs_conversion
|
||||
|| (provider_api_format == client_api_format && needs_conversion)
|
||||
{
|
||||
return Ok(None);
|
||||
}
|
||||
@@ -1551,6 +1549,33 @@ mod tests {
|
||||
assert_eq!(body_json, provider_body_json);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn allows_openai_cli_same_family_cross_format_sync_when_conversion_is_flagged() {
|
||||
let report_context = json!({
|
||||
"provider_api_format": "openai:compact",
|
||||
"client_api_format": "openai:cli",
|
||||
"needs_conversion": true,
|
||||
});
|
||||
let provider_body_json = json!({
|
||||
"id": "resp_family_123",
|
||||
"object": "response",
|
||||
"status": "completed",
|
||||
"output": []
|
||||
});
|
||||
|
||||
let body_json = maybe_build_openai_cli_same_family_sync_body_from_normalized_payload(
|
||||
"openai_cli_sync_finalize",
|
||||
200,
|
||||
Some(&report_context),
|
||||
Some(&provider_body_json),
|
||||
None,
|
||||
)
|
||||
.expect("openai-cli cross-family sync should succeed")
|
||||
.expect("body should exist");
|
||||
|
||||
assert_eq!(body_json, provider_body_json);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_openai_cli_same_family_error_body_json() {
|
||||
let report_context = json!({
|
||||
@@ -1816,6 +1841,37 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn standard_sync_finalize_product_handles_openai_cli_same_family_cross_format_body() {
|
||||
let report_context = json!({
|
||||
"provider_api_format": "openai:compact",
|
||||
"client_api_format": "openai:cli",
|
||||
"needs_conversion": true,
|
||||
});
|
||||
let provider_body_json = json!({
|
||||
"id": "resp_family_123",
|
||||
"object": "response",
|
||||
"status": "completed",
|
||||
"output": []
|
||||
});
|
||||
|
||||
let product = maybe_build_standard_sync_finalize_product_from_normalized_payload(
|
||||
"openai_cli_sync_finalize",
|
||||
200,
|
||||
Some(&report_context),
|
||||
Some(&provider_body_json),
|
||||
None,
|
||||
)
|
||||
.expect("dispatch should succeed");
|
||||
|
||||
assert_eq!(
|
||||
product,
|
||||
Some(StandardSyncFinalizeNormalizedProduct::SuccessBody(
|
||||
provider_body_json
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn standard_sync_finalize_product_handles_openai_chat_cross_format() {
|
||||
let report_context = json!({
|
||||
|
||||
Reference in New Issue
Block a user