mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-08-03 14:30:29 +00:00

* 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
41 lines
1.2 KiB
Rust
41 lines
1.2 KiB
Rust
use std::sync::Weak;
|
|
|
|
use strum_macros::Display;
|
|
|
|
use flowy_derive::{Flowy_Event, ProtoBuf_Enum};
|
|
use lib_dispatch::prelude::*;
|
|
|
|
use crate::event_handler::*;
|
|
use crate::manager::ChatManager;
|
|
|
|
pub fn init(chat_manager: Weak<ChatManager>) -> AFPlugin {
|
|
AFPlugin::new()
|
|
.name("Flowy-Chat")
|
|
.state(chat_manager)
|
|
.event(ChatEvent::SendMessage, send_chat_message_handler)
|
|
.event(ChatEvent::LoadPrevMessage, load_prev_message_handler)
|
|
.event(ChatEvent::LoadNextMessage, load_next_message_handler)
|
|
.event(ChatEvent::GetRelatedQuestion, get_related_question_handler)
|
|
.event(ChatEvent::GetAnswerForQuestion, get_answer_handler)
|
|
}
|
|
|
|
#[derive(Clone, Copy, PartialEq, Eq, Debug, Display, Hash, ProtoBuf_Enum, Flowy_Event)]
|
|
#[event_err = "FlowyError"]
|
|
pub enum ChatEvent {
|
|
/// Create a new workspace
|
|
#[event(input = "LoadPrevChatMessagePB", output = "ChatMessageListPB")]
|
|
LoadPrevMessage = 0,
|
|
|
|
#[event(input = "LoadNextChatMessagePB", output = "ChatMessageListPB")]
|
|
LoadNextMessage = 1,
|
|
|
|
#[event(input = "SendChatPayloadPB")]
|
|
SendMessage = 2,
|
|
|
|
#[event(input = "ChatMessageIdPB", output = "RepeatedRelatedQuestionPB")]
|
|
GetRelatedQuestion = 3,
|
|
|
|
#[event(input = "ChatMessageIdPB", output = "ChatMessagePB")]
|
|
GetAnswerForQuestion = 4,
|
|
}
|