Skip to content

Commit eea7480

Browse files
authored
Stablize the test verify_similarity_search_chat_completion (spiceai#5284)
* Further stablize document_similarity input snapshot * verify result content instead of snapshotting * allow model integration test run concurrently * test #1 * test #2 * test #3 * test #4 * test #5 * test #6 * test #7 * test #8 * test #9 * test #10 * test #10 * test #11 * remove temporary changes in the model workflow * display actual value found
1 parent 66b7654 commit eea7480

2 files changed

Lines changed: 26 additions & 24 deletions

File tree

crates/runtime/tests/models/openai.rs

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -672,13 +672,33 @@ async fn verify_similarity_search_chat_completion(
672672
a_str.cmp(&b_str)
673673
});
674674

675-
// Create a combined JSON array with all filtered values
676-
let combined_value = serde_json::Value::Array(stable_inputs);
675+
// Instead of creating a snapshot, verify keywords contain expected values
676+
let mut found_journalist = false;
677+
let mut found_vehicle = false;
678+
let mut actual_keywords = Vec::new();
679+
680+
for input in &stable_inputs {
681+
if let Some(keywords) = input.get("keywords").and_then(|k| k.as_array()) {
682+
actual_keywords.push(keywords.clone());
683+
for keyword in keywords {
684+
if let Some(keyword_str) = keyword.as_str() {
685+
if keyword_str.contains("journalist") {
686+
found_journalist = true;
687+
} else if keyword_str.contains("vehicle") {
688+
found_vehicle = true;
689+
}
690+
}
691+
}
692+
}
693+
}
677694

678-
// Verify Task History
679-
insta::assert_snapshot!(
680-
"chat_2_document_similarity_tasks",
681-
serde_json::to_string_pretty(&combined_value).expect("Failed to serialize task_input")
695+
assert!(
696+
found_journalist,
697+
"Expected to find 'journalist' in keywords, found {actual_keywords:?}",
698+
);
699+
assert!(
700+
found_vehicle,
701+
"Expected to find 'vehicle' in keywords, found {actual_keywords:?}",
682702
);
683703

684704
Ok(())

crates/runtime/tests/models/snapshots/integration_models__models__openai__chat_2_document_similarity_tasks.snap

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)