Skip to content

Commit

Permalink
chore: fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
appflowy committed Aug 12, 2024
1 parent 4d9d47b commit faac2c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion appflowy-local-ai/tests/chat_test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::collections::HashMap;

use appflowy_local_ai::ai_ops::{CompleteTextType, LocalAITranslateItem, LocalAITranslateRowData};
use appflowy_plugin::manager::PluginManager;
use serde_json::Value;
use std::env::temp_dir;
use std::path::PathBuf;
use std::sync::Arc;
Expand Down Expand Up @@ -51,7 +52,10 @@ async fn ci_chat_stream_test() {
let mut resp = test.stream_chat_message(&chat_id, "what is banana?").await;
let mut list = vec![];
while let Some(s) = resp.next().await {
list.push(String::from_utf8(s.unwrap().to_vec()).unwrap());
if let Value::Object(mut map) = s.unwrap() {
let s = map.remove("1").unwrap().as_str().unwrap().to_string();
list.push(s);
}
}

let answer = list.join("");
Expand Down
6 changes: 3 additions & 3 deletions appflowy-local-ai/tests/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use appflowy_local_ai::chat_plugin::{AIPluginConfig, AppFlowyLocalAI};
use appflowy_local_ai::embedding_plugin::{EmbeddingPluginConfig, LocalEmbedding};
use appflowy_plugin::error::PluginError;
use appflowy_plugin::manager::PluginManager;
use bytes::Bytes;
use serde_json::json;

use serde_json::{json, Value};
use simsimd::SpatialSimilarity;
use std::f64;
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -76,7 +76,7 @@ impl LocalAITest {
&self,
chat_id: &str,
message: &str,
) -> ReceiverStream<Result<Bytes, PluginError>> {
) -> ReceiverStream<Result<Value, PluginError>> {
self
.local_ai
.stream_question(chat_id, message, json!([]))
Expand Down

0 comments on commit faac2c6

Please sign in to comment.