Skip to content

Commit

Permalink
chore: update test
Browse files Browse the repository at this point in the history
  • Loading branch information
appflowy committed Jul 6, 2024
1 parent c9b4876 commit 5904692
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions appflowy-local-ai/tests/chat_test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async fn ci_chat_stream_test() {
test.init_embedding_plugin().await;
let chat_id = uuid::Uuid::new_v4().to_string();

let mut resp = test.stream_chat_message(&chat_id, "hello world").await;
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());
Expand All @@ -39,6 +39,8 @@ async fn ci_chat_stream_test() {
let answer = list.join("");
eprintln!("response: {:?}", answer);

let score = test.calculate_similarity(&answer, "Hello! How can I help you today? Is there something specific you would like to know or discuss").await;
let expected = r#"banana is a fruit that belongs to the genus _______, which also includes other fruits such as apple and pear. It has several varieties with different shapes, colors, and flavors depending on where it grows. Bananas are typically green or yellow in color and have smooth skin that peels off easily when ripe. They are sweet and juicy, often eaten raw or roasted, and can also be used for cooking and baking. In some cultures, banana is considered a symbol of good luck, fertility, and prosperity. Bananas originated in Southeast Asia, where they were cultivated by early humans thousands of years ago. They are now grown around the world as a major crop, with significant production in many countries including the United States, Brazil, India, and China#"#;

let score = test.calculate_similarity(&answer, expected).await;
assert!(score > 0.7, "score: {}", score);
}

0 comments on commit 5904692

Please sign in to comment.