fix: parse cloudflare run results
This commit is contained in:
@@ -218,7 +218,7 @@ pub async fn create_system_one(
|
|||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
let response = match upstream_response.json().await {
|
let response: serde_json::Value = match upstream_response.json().await {
|
||||||
Ok(response) => response,
|
Ok(response) => response,
|
||||||
Err(json_error) => {
|
Err(json_error) => {
|
||||||
tracing::error!(?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)
|
Err(SystemOneError::NoneSucceeded)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user