chore: fix flaky test (#1135)

This commit is contained in:
Nathan.fooo 2025-01-07 15:12:37 +08:00 committed by GitHub
parent 48224c6fcc
commit 9f16d040b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 25 additions and 8 deletions

View File

@ -121,7 +121,7 @@ AI_OPENAI_API_KEY=
AI_SERVER_PORT=5001
AI_SERVER_HOST=localhost
AI_DATABASE_URL=postgresql+psycopg://postgres:password@localhost:5432/postgres
AI_REDIS_URL=redis://redis:6379
AI_REDIS_URL=redis://localhost:6379
LOCAL_AI_TEST_ENABLED=false
AI_APPFLOWY_BUCKET_NAME=appflowy
AI_APPFLOWY_HOST=http://localhost:8000
@ -131,7 +131,7 @@ AI_AWS_SECRET_ACCESS_KEY=${AWS_SECRET}
# AppFlowy Indexer
APPFLOWY_INDEXER_ENABLED=true
APPFLOWY_INDEXER_DATABASE_URL=postgres://postgres:password@localhost:5432/postgres
APPFLOWY_INDEXER_REDIS_URL=redis://redis:6379
APPFLOWY_INDEXER_REDIS_URL=redis://localhost:6379
APPFLOWY_INDEXER_EMBEDDING_BUFFER_SIZE=5000
# AppFlowy Collaborate

View File

@ -458,6 +458,7 @@ pub struct CalculateSimilarityParams {
pub workspace_id: String,
pub input: String,
pub expected: String,
pub use_embedding: bool,
}
#[derive(Clone, Debug, Serialize, Deserialize)]

View File

@ -640,11 +640,13 @@ impl TestClient {
input: &str,
expected: &str,
score: f64,
use_embedding: bool,
) {
let params = CalculateSimilarityParams {
workspace_id: workspace_id.to_string(),
input: input.to_string(),
expected: expected.to_string(),
use_embedding,
};
let resp = self.api_client.calculate_similarity(params).await.unwrap();
assert!(

View File

@ -111,7 +111,13 @@ async fn chat_with_multiple_selected_source_test() {
.await;
let expected_unknown_japan_answer = r#"I dont know the date for your trip to Japan"#;
test_client
.assert_similarity(&workspace_id, &answer, expected_unknown_japan_answer, 0.7)
.assert_similarity(
&workspace_id,
&answer,
expected_unknown_japan_answer,
0.7,
true,
)
.await;
// update chat context to snowboarding_in_japan_plan
@ -136,7 +142,7 @@ async fn chat_with_multiple_selected_source_test() {
You take off to Japan on **January 7th**
"#;
test_client
.assert_similarity(&workspace_id, &answer, expected, 0.8)
.assert_similarity(&workspace_id, &answer, expected, 0.8, false)
.await;
// Ask question for alex to make sure two documents are treated as chat context
@ -149,7 +155,7 @@ async fn chat_with_multiple_selected_source_test() {
.await;
let expected = r#"Tennis, basketball, cycling, badminton, snowboarding."#;
test_client
.assert_similarity(&workspace_id, &answer, expected, 0.8)
.assert_similarity(&workspace_id, &answer, expected, 0.8, true)
.await;
// remove the Japan plan and check the response. After remove the Japan plan, the chat should not
@ -172,7 +178,13 @@ async fn chat_with_multiple_selected_source_test() {
)
.await;
test_client
.assert_similarity(&workspace_id, &answer, expected_unknown_japan_answer, 0.7)
.assert_similarity(
&workspace_id,
&answer,
expected_unknown_japan_answer,
0.7,
true,
)
.await;
}
@ -233,7 +245,7 @@ async fn chat_with_selected_source_override_test() {
Overall, Alex balances his work as a software programmer with his passion for sports, finding excitement and freedom in each activity.
"#;
test_client
.assert_similarity(&workspace_id, &answer, expected, 0.8)
.assert_similarity(&workspace_id, &answer, expected, 0.8, true)
.await;
// remove all content for given document
@ -276,7 +288,7 @@ Overall, Alex balances his work as a software programmer with his passion for sp
he certainly has many experiences in the culinary world, where he enjoys savoring flavors and discovering new dishes
"#;
test_client
.assert_similarity(&workspace_id, &answer, expected, 0.8)
.assert_similarity(&workspace_id, &answer, expected, 0.8, true)
.await;
}

View File

@ -79,6 +79,7 @@ reprisal. Lack of Commitment Without clarity and buy-in, team decisions bec
The Five Dysfunctions of a Team by Patrick Lencioni The Five Dysfunctions of a Team by Patrick Lenci"
"#
.to_string(),
use_embedding: true,
};
let score = test_client
.api_client
@ -131,6 +132,7 @@ The Five Dysfunctions of a Team by Patrick Lencioni The Five Dysfunctions of a T
ultimately leading her team toward improved collaboration and performance.
"#
.to_string(),
use_embedding: true,
};
let score = test_client
.api_client