Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

chore: show ai service error (#5675)

Nathan.fooo7a3f013a8767
diff --git a/frontend/rust-lib/flowy-chat/src/chat.rs b/frontend/rust-lib/flowy-chat/src/chat.rs
index 2854d12a92..6c5e06d7a8 100644
--- a/frontend/rust-lib/flowy-chat/src/chat.rs
+++ b/frontend/rust-lib/flowy-chat/src/chat.rs
@@ -140,12 +140,14 @@ impl Chat {
send_notification(&chat_id, ChatNotification::StreamChatMessageError)
.payload(pb)
.send();
- break;
+ return Err(err);
},
}
}
},
Err(err) => {
+ error!("[Chat] failed to stream answer: {}", err);
+ let _ = text_sink.send(format!("error:{}", err)).await;
let pb = ChatMessageErrorPB {
chat_id: chat_id.clone(),
error_message: err.to_string(),
@@ -153,10 +155,15 @@ impl Chat {
send_notification(&chat_id, ChatNotification::StreamChatMessageError)
.payload(pb)
.send();
+ return Err(err);
},
}
send_notification(&chat_id, ChatNotification::FinishStreaming).send();
+ if stream_buffer.lock().await.is_empty() {
+ return Ok(());
+ }
+
let answer = cloud_service
.save_answer(
&workspace_id,
@@ -166,7 +173,6 @@ impl Chat {
)
.await?;
Self::save_answer(uid, &chat_id, &user_service, answer)?;
-
Ok::<(), FlowyError>(())
});