From 9b4bfce616c335eb2dec9a9295e0c67c0a559848 Mon Sep 17 00:00:00 2001 From: "Nathan.fooo" <86001920+appflowy@users.noreply.github.com> Date: Thu, 30 May 2024 07:50:25 +0800 Subject: [PATCH] chore: fix ai client test (#589) --- Cargo.lock | 1 + libs/appflowy-ai-client/Cargo.toml | 1 + libs/appflowy-ai-client/tests/chat_test/qa_test.rs | 3 ++- services/appflowy-history/src/core/manager.rs | 4 ++++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index ad55453c..af1a6fd9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -576,6 +576,7 @@ dependencies = [ "tokio", "tracing", "tracing-subscriber", + "uuid", ] [[package]] diff --git a/libs/appflowy-ai-client/Cargo.toml b/libs/appflowy-ai-client/Cargo.toml index 0bd08efc..992fd39f 100644 --- a/libs/appflowy-ai-client/Cargo.toml +++ b/libs/appflowy-ai-client/Cargo.toml @@ -17,6 +17,7 @@ serde_repr = { version = "0.1", optional = true } [dev-dependencies] tokio = { version = "1.37.0", features = ["macros", "test-util"] } tracing-subscriber = { version = "0.3.18", features = ["registry", "env-filter", "ansi", "json"] } +uuid = { version = "1.6", features = ["v4"] } [features] default = ["client-api"] diff --git a/libs/appflowy-ai-client/tests/chat_test/qa_test.rs b/libs/appflowy-ai-client/tests/chat_test/qa_test.rs index aaa5fb25..d53a0163 100644 --- a/libs/appflowy-ai-client/tests/chat_test/qa_test.rs +++ b/libs/appflowy-ai-client/tests/chat_test/qa_test.rs @@ -4,8 +4,9 @@ use crate::appflowy_ai_client; async fn qa_test() { let client = appflowy_ai_client(); client.health_check().await.unwrap(); + let chat_id = uuid::Uuid::new_v4().to_string(); let resp = client - .send_question("fake_chat_id", "I feel hungry") + .send_question(&chat_id, "I feel hungry") .await .unwrap(); assert!(!resp.content.is_empty()); diff --git a/services/appflowy-history/src/core/manager.rs b/services/appflowy-history/src/core/manager.rs index 84c14bdd..2a28e44f 100644 --- a/services/appflowy-history/src/core/manager.rs +++ b/services/appflowy-history/src/core/manager.rs @@ -97,6 +97,10 @@ async fn spawn_control_group( .await { if let Some(handles) = weak_handles.upgrade() { + if messages.is_empty() { + continue; + } + trace!("[History] received {} control messages", messages.len()); for message in &messages { if let Ok(event) = CollabControlEvent::decode(&message.data) {