mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-04 16:37:46 +08:00
fix(conversion): improve stream failures and diagnostic exports
This commit is contained in:
@@ -34,6 +34,7 @@ pub struct CandidateFailureDiagnostic {
|
||||
client_api_format: Option<String>,
|
||||
provider_api_format: Option<String>,
|
||||
safe_to_show: bool,
|
||||
details: Option<Value>,
|
||||
}
|
||||
|
||||
impl CandidateFailureDiagnostic {
|
||||
@@ -50,6 +51,7 @@ impl CandidateFailureDiagnostic {
|
||||
client_api_format: None,
|
||||
provider_api_format: None,
|
||||
safe_to_show: true,
|
||||
details: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +60,11 @@ impl CandidateFailureDiagnostic {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn details(mut self, details: Value) -> Self {
|
||||
self.details = Some(details);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn formats(
|
||||
mut self,
|
||||
client_api_format: impl Into<String>,
|
||||
@@ -219,6 +226,10 @@ impl CandidateFailureDiagnostic {
|
||||
"client_api_format": self.client_api_format,
|
||||
"provider_api_format": self.provider_api_format,
|
||||
"safe_to_show": self.safe_to_show,
|
||||
"details": self.details,
|
||||
"stage": "request",
|
||||
"source_format": self.client_api_format,
|
||||
"target_format": self.provider_api_format,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,6 +224,7 @@ fn diagnostic_from_format_error(
|
||||
format_error_path(error),
|
||||
format_error_message(error, client_api_format, provider_api_format),
|
||||
)
|
||||
.details(error.diagnostic())
|
||||
}
|
||||
|
||||
fn format_error_path(error: &FormatError) -> String {
|
||||
@@ -982,6 +983,23 @@ mod tests {
|
||||
"request_conversion"
|
||||
);
|
||||
assert_eq!(diagnostic["failure_diagnostic"]["path"], "$.n");
|
||||
assert_eq!(diagnostic["failure_diagnostic"]["stage"], "request");
|
||||
assert_eq!(
|
||||
diagnostic["failure_diagnostic"]["details"]["code"],
|
||||
"lossy_conversion_blocked"
|
||||
);
|
||||
assert_eq!(
|
||||
diagnostic["failure_diagnostic"]["details"]["path_source"],
|
||||
"structured"
|
||||
);
|
||||
assert_eq!(
|
||||
diagnostic["failure_diagnostic"]["source_format"],
|
||||
"openai:chat"
|
||||
);
|
||||
assert_eq!(
|
||||
diagnostic["failure_diagnostic"]["target_format"],
|
||||
"openai:responses"
|
||||
);
|
||||
assert_eq!(diagnostic["request_conversion_error"]["path"], "$.n");
|
||||
assert!(diagnostic["failure_diagnostic"]["message"]
|
||||
.as_str()
|
||||
|
||||
Reference in New Issue
Block a user