2024-06-25 01:59:38 +02:00
|
|
|
use client_api::entity::ai_dto::{CompletionType, RepeatedRelatedQuestion};
|
2024-06-03 14:27:28 +08:00
|
|
|
use client_api::entity::{ChatMessageType, MessageCursor, RepeatedChatMessage};
|
2024-06-25 01:59:38 +02:00
|
|
|
use flowy_chat_pub::cloud::{
|
|
|
|
ChatCloudService, ChatMessage, ChatMessageStream, StreamAnswer, StreamComplete,
|
|
|
|
};
|
2024-06-03 14:27:28 +08:00
|
|
|
use flowy_error::FlowyError;
|
|
|
|
use lib_infra::async_trait::async_trait;
|
|
|
|
use lib_infra::future::FutureResult;
|
|
|
|
|
|
|
|
pub(crate) struct DefaultChatCloudServiceImpl;
|
|
|
|
|
|
|
|
#[async_trait]
|
|
|
|
impl ChatCloudService for DefaultChatCloudServiceImpl {
|
|
|
|
fn create_chat(
|
|
|
|
&self,
|
|
|
|
_uid: &i64,
|
|
|
|
_workspace_id: &str,
|
|
|
|
_chat_id: &str,
|
|
|
|
) -> FutureResult<(), FlowyError> {
|
|
|
|
FutureResult::new(async move {
|
|
|
|
Err(FlowyError::not_support().with_context("Chat is not supported in local server."))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn send_chat_message(
|
|
|
|
&self,
|
|
|
|
_workspace_id: &str,
|
|
|
|
_chat_id: &str,
|
|
|
|
_message: &str,
|
|
|
|
_message_type: ChatMessageType,
|
|
|
|
) -> Result<ChatMessageStream, FlowyError> {
|
2024-06-09 14:02:32 +08:00
|
|
|
Err(FlowyError::not_support().with_context("Chat is not supported in local server."))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn send_question(
|
|
|
|
&self,
|
|
|
|
_workspace_id: &str,
|
|
|
|
_chat_id: &str,
|
|
|
|
_message: &str,
|
|
|
|
_message_type: ChatMessageType,
|
|
|
|
) -> FutureResult<ChatMessage, FlowyError> {
|
|
|
|
FutureResult::new(async move {
|
|
|
|
Err(FlowyError::not_support().with_context("Chat is not supported in local server."))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
fn save_answer(
|
|
|
|
&self,
|
|
|
|
_workspace_id: &str,
|
|
|
|
_chat_id: &str,
|
|
|
|
_message: &str,
|
|
|
|
_question_id: i64,
|
|
|
|
) -> FutureResult<ChatMessage, FlowyError> {
|
|
|
|
FutureResult::new(async move {
|
|
|
|
Err(FlowyError::not_support().with_context("Chat is not supported in local server."))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn stream_answer(
|
|
|
|
&self,
|
|
|
|
_workspace_id: &str,
|
|
|
|
_chat_id: &str,
|
|
|
|
_message_id: i64,
|
|
|
|
) -> Result<StreamAnswer, FlowyError> {
|
2024-06-03 14:27:28 +08:00
|
|
|
Err(FlowyError::not_support().with_context("Chat is not supported in local server."))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn get_chat_messages(
|
|
|
|
&self,
|
|
|
|
_workspace_id: &str,
|
|
|
|
_chat_id: &str,
|
|
|
|
_offset: MessageCursor,
|
|
|
|
_limit: u64,
|
|
|
|
) -> FutureResult<RepeatedChatMessage, FlowyError> {
|
|
|
|
FutureResult::new(async move {
|
|
|
|
Err(FlowyError::not_support().with_context("Chat is not supported in local server."))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
fn get_related_message(
|
|
|
|
&self,
|
|
|
|
_workspace_id: &str,
|
|
|
|
_chat_id: &str,
|
|
|
|
_message_id: i64,
|
|
|
|
) -> FutureResult<RepeatedRelatedQuestion, FlowyError> {
|
|
|
|
FutureResult::new(async move {
|
|
|
|
Err(FlowyError::not_support().with_context("Chat is not supported in local server."))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
fn generate_answer(
|
|
|
|
&self,
|
|
|
|
_workspace_id: &str,
|
|
|
|
_chat_id: &str,
|
|
|
|
_question_message_id: i64,
|
|
|
|
) -> FutureResult<ChatMessage, FlowyError> {
|
|
|
|
FutureResult::new(async move {
|
|
|
|
Err(FlowyError::not_support().with_context("Chat is not supported in local server."))
|
|
|
|
})
|
|
|
|
}
|
2024-06-25 01:59:38 +02:00
|
|
|
|
|
|
|
async fn stream_complete(
|
|
|
|
&self,
|
|
|
|
_workspace_id: &str,
|
|
|
|
_text: &str,
|
|
|
|
_complete_type: CompletionType,
|
|
|
|
) -> Result<StreamComplete, FlowyError> {
|
|
|
|
Err(FlowyError::not_support().with_context("complete text is not supported in local server."))
|
|
|
|
}
|
2024-06-03 14:27:28 +08:00
|
|
|
}
|