mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: clippy
This commit is contained in:
@ -235,7 +235,10 @@ impl ChatCloudService for ChatService {
|
||||
message: &str,
|
||||
message_type: ChatMessageType,
|
||||
) -> Result<ChatMessageStream, FlowyError> {
|
||||
todo!()
|
||||
self
|
||||
.cloud_service
|
||||
.send_chat_message(workspace_id, chat_id, message, message_type)
|
||||
.await
|
||||
}
|
||||
|
||||
fn send_question(
|
||||
@ -274,7 +277,13 @@ impl ChatCloudService for ChatService {
|
||||
offset: MessageCursor,
|
||||
limit: u64,
|
||||
) -> FutureResult<RepeatedChatMessage, FlowyError> {
|
||||
todo!()
|
||||
FutureResult::new(async move {
|
||||
RepeatedChatMessage {
|
||||
messages: vec![],
|
||||
has_more: false,
|
||||
total: 0,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn get_related_message(
|
||||
@ -283,7 +292,12 @@ impl ChatCloudService for ChatService {
|
||||
chat_id: &str,
|
||||
message_id: i64,
|
||||
) -> FutureResult<RepeatedRelatedQuestion, FlowyError> {
|
||||
todo!()
|
||||
FutureResult::new(async move {
|
||||
RepeatedRelatedQuestion {
|
||||
message_id,
|
||||
items: vec![],
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn generate_answer(
|
||||
|
@ -102,7 +102,6 @@ impl Plugin {
|
||||
let value = rx
|
||||
.await
|
||||
.map_err(|err| Error::Internal(anyhow!("error waiting for async response: {:?}", err)))??;
|
||||
|
||||
let value = P::parse_response(value)?;
|
||||
Ok(value)
|
||||
}
|
||||
|
@ -143,6 +143,9 @@ impl<W: Write> RawPeer<W> {
|
||||
let mut pending = self.0.pending.lock();
|
||||
pending.insert(id, rh);
|
||||
}
|
||||
|
||||
// Call the ResponseHandler if the send fails. Otherwise, the response will be
|
||||
// called in handle_response.
|
||||
if let Err(e) = self.send(&json!({
|
||||
"id": id,
|
||||
"method": method,
|
||||
@ -162,7 +165,10 @@ impl<W: Write> RawPeer<W> {
|
||||
pending.remove(&id)
|
||||
};
|
||||
match handler {
|
||||
Some(response_handler) => response_handler.invoke(resp),
|
||||
Some(response_handler) => {
|
||||
//
|
||||
response_handler.invoke(resp)
|
||||
},
|
||||
None => warn!("[RPC] id {} not found in pending", id),
|
||||
}
|
||||
}
|
||||
@ -244,6 +250,10 @@ impl<W: Write> Clone for RawPeer<W> {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ResponsePayload {
|
||||
value: Value,
|
||||
}
|
||||
|
||||
pub type Response = Result<Value, RemoteError>;
|
||||
enum ResponseHandler {
|
||||
Chan(mpsc::Sender<Result<Value, Error>>),
|
||||
|
@ -32,6 +32,25 @@ impl ChatPluginOperation {
|
||||
Ok(resp)
|
||||
}
|
||||
|
||||
pub async fn stream_message(
|
||||
&self,
|
||||
chat_id: &str,
|
||||
plugin_id: PluginId,
|
||||
message: &str,
|
||||
) -> Result<String, Error> {
|
||||
let plugin = self
|
||||
.plugin
|
||||
.upgrade()
|
||||
.ok_or(Error::Internal(anyhow!("Plugin is dropped")))?;
|
||||
|
||||
let params =
|
||||
json!({"chat_id": chat_id, "method": "stream_answer", "params": {"content": message}});
|
||||
let resp = plugin
|
||||
.async_send_request::<ChatResponseParser>("handle", ¶ms)
|
||||
.await?;
|
||||
Ok(resp)
|
||||
}
|
||||
|
||||
pub async fn get_related_questions(
|
||||
&self,
|
||||
chat_id: &str,
|
||||
|
Reference in New Issue
Block a user