diff --git a/src-tauri/src/assistant/mod.rs b/src-tauri/src/assistant/mod.rs index e4ec4648..c4eb4467 100644 --- a/src-tauri/src/assistant/mod.rs +++ b/src-tauri/src/assistant/mod.rs @@ -139,13 +139,10 @@ pub async fn new_chat( .await .map_err(|e| format!("Error sending message: {}", e))?; - let text = response - .text() - .await - .map_err(|e| format!("Failed to read response body: {}", e))?; + let body_text = common::http::get_response_body_text(response).await?; let chat_response: GetResponse = - serde_json::from_str(&text).map_err(|e| format!("Failed to parse response JSON: {}", e))?; + serde_json::from_str(&body_text).map_err(|e| format!("Failed to parse response JSON: {}", e))?; if chat_response.result != "created" { return Err(format!("Unexpected result: {}", chat_response.result)); @@ -179,8 +176,8 @@ pub async fn send_message( query_params, Some(body), ) - .await - .map_err(|e| format!("Error cancel session: {}", e))?; + .await + .map_err(|e| format!("Error cancel session: {}", e))?; common::http::get_response_body_text(response).await } @@ -222,8 +219,8 @@ pub async fn update_session_chat( None, Some(reqwest::Body::from(serde_json::to_string(&body).unwrap())), ) - .await - .map_err(|e| format!("Error updating session: {}", e))?; + .await + .map_err(|e| format!("Error updating session: {}", e))?; Ok(response.status().is_success()) }