Fix summarize response handling

This commit is contained in:
Tyler Hallada 2024-09-08 20:30:09 -04:00
parent a85cb7891e
commit 27467b462e

View File

@ -73,10 +73,15 @@ struct Message {
} }
#[derive(Deserialize)] #[derive(Deserialize)]
struct SummarizeResponse { struct SummarizeResult {
summary: String, summary: String,
} }
#[derive(Deserialize)]
struct SummarizeResponse {
result: SummarizeResult,
}
async fn request_ai_summarization( async fn request_ai_summarization(
base_url: &str, base_url: &str,
api_key: &str, api_key: &str,
@ -101,7 +106,7 @@ async fn request_ai_summarization(
if response.status().is_success() { if response.status().is_success() {
console_log!("request_ai_summarization success"); console_log!("request_ai_summarization success");
let summarize_response: SummarizeResponse = response.json().await?; let summarize_response: SummarizeResponse = response.json().await?;
Ok(summarize_response.summary) Ok(summarize_response.result.summary)
} else { } else {
let error_message = response.text().await?; let error_message = response.text().await?;
console_log!("request_ai_summarization error: {}", error_message); console_log!("request_ai_summarization error: {}", error_message);