Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix flaky test #1135

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dev.env
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions libs/appflowy-ai-client/src/dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 2 additions & 0 deletions libs/client-api-test/src/test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
24 changes: 18 additions & 6 deletions tests/ai_test/chat_with_selected_doc_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,13 @@ async fn chat_with_multiple_selected_source_test() {
.await;
let expected_unknown_japan_answer = r#"I don’t 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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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;
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions tests/search/document_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading