Nathan.fooo aec7bc847e
feat: AI chat (#5383)
* chore: ai type

* chore: use patch to fix version issue

* chore: update

* chore: update

* chore: integrate client api

* chore: add schema

* chore: setup event

* chore: add event test

* chore: add test

* chore: update test

* chore: load chat message

* chore: load chat message

* chore: chat ui

* chore: disable create chat

* chore: update client api

* chore: disable chat

* chore: ui theme

* chore: ui theme

* chore: copy message

* chore: fix test

* chore: show error

* chore: update bloc

* chore: update test

* chore: lint

* chore: icon

* chore: hover

* chore: show unsupported page

* chore: adjust mobile ui

* chore: adjust view title bar

* chore: return related question

* chore: error page

* chore: error page

* chore: code format

* chore: prompt

* chore: fix test

* chore: ui adjust

* chore: disable create chat

* chore: add loading page

* chore: fix test

* chore: disable chat action

* chore: add maximum text limit
2024-06-03 14:27:28 +08:00

41 lines
1.2 KiB
Rust

use flowy_derive::ProtoBuf_Enum;
use flowy_notification::NotificationBuilder;
const CHAT_OBSERVABLE_SOURCE: &str = "Chat";
#[derive(ProtoBuf_Enum, Debug, Default)]
pub enum ChatNotification {
#[default]
Unknown = 0,
DidLoadLatestChatMessage = 1,
DidLoadPrevChatMessage = 2,
DidReceiveChatMessage = 3,
StreamChatMessageError = 4,
FinishAnswerQuestion = 5,
LastUserSentMessage = 6,
}
impl std::convert::From<ChatNotification> for i32 {
fn from(notification: ChatNotification) -> Self {
notification as i32
}
}
impl std::convert::From<i32> for ChatNotification {
fn from(notification: i32) -> Self {
match notification {
1 => ChatNotification::DidLoadLatestChatMessage,
2 => ChatNotification::DidLoadPrevChatMessage,
3 => ChatNotification::DidReceiveChatMessage,
4 => ChatNotification::StreamChatMessageError,
5 => ChatNotification::FinishAnswerQuestion,
6 => ChatNotification::LastUserSentMessage,
_ => ChatNotification::Unknown,
}
}
}
#[tracing::instrument(level = "trace")]
pub(crate) fn send_notification(id: &str, ty: ChatNotification) -> NotificationBuilder {
NotificationBuilder::new(id, ty, CHAT_OBSERVABLE_SOURCE)
}