fix: parse cloudflare run results

This commit is contained in:
2026-10-10 20:15:25 -04:00
parent c88874948a
commit f778fae70c

View File

@@ -218,7 +218,7 @@ pub async fn create_system_one(
continue;
};
let response = match upstream_response.json().await {
let response: serde_json::Value = match upstream_response.json().await {
Ok(response) => response,
Err(json_error) => {
tracing::error!(?json_error);
@@ -226,7 +226,28 @@ pub async fn create_system_one(
}
};
return Ok(SystemOneResponse(response));
match openai::system_one::SystemOneResponse::deserialize(
response.clone(), // TODO: not need to clone
) {
Ok(response) => return Ok(SystemOneResponse(response)),
Err(structure_error) => {
#[derive(Deserialize)]
struct CloudflareRunResponse {
result: openai::system_one::SystemOneResponse<String>,
success: bool,
errors: Vec<serde_json::Value>, // TODO
messages: Vec<serde_json::Value>, // TODO
}
match CloudflareRunResponse::deserialize(response) {
Ok(response) => return Ok(SystemOneResponse(response.result)),
Err(cloudflare_structure_error) => {
tracing::error!(?structure_error);
tracing::error!(?cloudflare_structure_error);
}
}
}
}
}
Err(SystemOneError::NoneSucceeded)
}