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