mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-09-03 22:05:49 +00:00

* chore: load plugin * chore: sidecar * chore: fix test * chore: clippy * chore: save chat config * chore: arc plugin * chore: add plugins * chore: clippy * chore: test streaming * chore: config chat * chore: stream message * chore: response with local ai * chore: fix compile * chore: config ui * chore: fix load plugin * chore: add docs * chore: update docs * chore: disable local ai * chore: fix compile * chore: clippy
78 lines
2.0 KiB
Rust
78 lines
2.0 KiB
Rust
use bytes::Bytes;
|
|
pub use client_api::entity::ai_dto::{
|
|
CompletionType, RelatedQuestion, RepeatedRelatedQuestion, StringOrMessage,
|
|
};
|
|
pub use client_api::entity::{
|
|
ChatAuthorType, ChatMessage, ChatMessageType, MessageCursor, QAChatMessage, RepeatedChatMessage,
|
|
};
|
|
use client_api::error::AppResponseError;
|
|
use flowy_error::FlowyError;
|
|
use futures::stream::BoxStream;
|
|
use lib_infra::async_trait::async_trait;
|
|
use lib_infra::future::FutureResult;
|
|
|
|
pub type ChatMessageStream = BoxStream<'static, Result<ChatMessage, AppResponseError>>;
|
|
pub type StreamAnswer = BoxStream<'static, Result<Bytes, FlowyError>>;
|
|
pub type StreamComplete = BoxStream<'static, Result<Bytes, AppResponseError>>;
|
|
#[async_trait]
|
|
pub trait ChatCloudService: Send + Sync + 'static {
|
|
fn create_chat(
|
|
&self,
|
|
uid: &i64,
|
|
workspace_id: &str,
|
|
chat_id: &str,
|
|
) -> FutureResult<(), FlowyError>;
|
|
|
|
fn save_question(
|
|
&self,
|
|
workspace_id: &str,
|
|
chat_id: &str,
|
|
message: &str,
|
|
message_type: ChatMessageType,
|
|
) -> FutureResult<ChatMessage, FlowyError>;
|
|
|
|
fn save_answer(
|
|
&self,
|
|
workspace_id: &str,
|
|
chat_id: &str,
|
|
message: &str,
|
|
question_id: i64,
|
|
) -> FutureResult<ChatMessage, FlowyError>;
|
|
|
|
async fn ask_question(
|
|
&self,
|
|
workspace_id: &str,
|
|
chat_id: &str,
|
|
message_id: i64,
|
|
) -> Result<StreamAnswer, FlowyError>;
|
|
|
|
async fn generate_answer(
|
|
&self,
|
|
workspace_id: &str,
|
|
chat_id: &str,
|
|
question_message_id: i64,
|
|
) -> Result<ChatMessage, FlowyError>;
|
|
|
|
fn get_chat_messages(
|
|
&self,
|
|
workspace_id: &str,
|
|
chat_id: &str,
|
|
offset: MessageCursor,
|
|
limit: u64,
|
|
) -> FutureResult<RepeatedChatMessage, FlowyError>;
|
|
|
|
fn get_related_message(
|
|
&self,
|
|
workspace_id: &str,
|
|
chat_id: &str,
|
|
message_id: i64,
|
|
) -> FutureResult<RepeatedRelatedQuestion, FlowyError>;
|
|
|
|
async fn stream_complete(
|
|
&self,
|
|
workspace_id: &str,
|
|
text: &str,
|
|
complete_type: CompletionType,
|
|
) -> Result<StreamComplete, FlowyError>;
|
|
}
|