Skip to content

Commit

Permalink
chore: show ai service error (AppFlowy-IO#5675)
Browse files Browse the repository at this point in the history
  • Loading branch information
appflowy authored Jul 2, 2024
1 parent 8c1520b commit 7a3f013
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions frontend/rust-lib/flowy-chat/src/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,23 +140,30 @@ 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(),
};
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,
Expand All @@ -166,7 +173,6 @@ impl Chat {
)
.await?;
Self::save_answer(uid, &chat_id, &user_service, answer)?;

Ok::<(), FlowyError>(())
});

Expand Down

0 comments on commit 7a3f013

Please sign in to comment.