mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: show ai service error (#5675)
This commit is contained in:
@ -140,12 +140,14 @@ impl Chat {
|
|||||||
send_notification(&chat_id, ChatNotification::StreamChatMessageError)
|
send_notification(&chat_id, ChatNotification::StreamChatMessageError)
|
||||||
.payload(pb)
|
.payload(pb)
|
||||||
.send();
|
.send();
|
||||||
break;
|
return Err(err);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
error!("[Chat] failed to stream answer: {}", err);
|
||||||
|
let _ = text_sink.send(format!("error:{}", err)).await;
|
||||||
let pb = ChatMessageErrorPB {
|
let pb = ChatMessageErrorPB {
|
||||||
chat_id: chat_id.clone(),
|
chat_id: chat_id.clone(),
|
||||||
error_message: err.to_string(),
|
error_message: err.to_string(),
|
||||||
@ -153,10 +155,15 @@ impl Chat {
|
|||||||
send_notification(&chat_id, ChatNotification::StreamChatMessageError)
|
send_notification(&chat_id, ChatNotification::StreamChatMessageError)
|
||||||
.payload(pb)
|
.payload(pb)
|
||||||
.send();
|
.send();
|
||||||
|
return Err(err);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
send_notification(&chat_id, ChatNotification::FinishStreaming).send();
|
send_notification(&chat_id, ChatNotification::FinishStreaming).send();
|
||||||
|
if stream_buffer.lock().await.is_empty() {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
let answer = cloud_service
|
let answer = cloud_service
|
||||||
.save_answer(
|
.save_answer(
|
||||||
&workspace_id,
|
&workspace_id,
|
||||||
@ -166,7 +173,6 @@ impl Chat {
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
Self::save_answer(uid, &chat_id, &user_service, answer)?;
|
Self::save_answer(uid, &chat_id, &user_service, answer)?;
|
||||||
|
|
||||||
Ok::<(), FlowyError>(())
|
Ok::<(), FlowyError>(())
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user