Skip to content

Commit

Permalink
fix digits rounding differences in CI
Browse files Browse the repository at this point in the history
Signed-off-by: Mingshi Liu <[email protected]>
  • Loading branch information
mingshl committed Mar 6, 2024
1 parent 9f8049a commit ebb4182
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
20 changes: 9 additions & 11 deletions src/test/java/org/opensearch/integTest/RAGToolIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,11 @@ public void testRAGToolWithNeuralQuery() {
// neural query to test match exact same text case, doc0 match with higher score
String result1 = executeAgent(agentId, "{\"parameters\": {\"question\": \"hello\"}}");

assertEquals(
"The agent execute response not equal with expected.",
"{\"_index\":\"test_neural_index\",\"_source\":{\"text\":\"hello world\"},\"_id\":\"0\",\"_score\":0.56714886}\n"
+ "{\"_index\":\"test_neural_index\",\"_source\":{\"text\":\"a b\"},\"_id\":\"1\",\"_score\":0.24236833}\n",
result1
// To allow digits variation from model output, using string contains to match
assertTrue(
result1.contains("{\"_index\":\"test_neural_index\",\"_source\":{\"text\":\"hello world\"},\"_id\":\"0\",\"_score\":0.5671488")
);
assertTrue(result1.contains("{\"_index\":\"test_neural_index\",\"_source\":{\"text\":\"a b\"},\"_id\":\"1\",\"_score\":0.2423683"));

// if blank input, call onFailure and get exception
Exception exception = assertThrows(ResponseException.class, () -> executeAgent(agentId, "{\"parameters\": {\"question\": \"\"}}"));
Expand Down Expand Up @@ -335,12 +334,11 @@ public void testRAGToolWithNeuralSparseQueryAndLLM_withIllegalSourceField_thenGe
public void testRAGToolWithNeuralQuery_withIllegalSourceField_thenGetEmptySource() {
String agentId = createAgent(registerAgentWithNeuralQueryRequestBody.replace("text", "text2"));
String result = executeAgent(agentId, "{\"parameters\": {\"question\": \"a\"}}");
assertEquals(
"The agent execute response not equal with expected.",
"{\"_index\":\"test_neural_index\",\"_source\":{},\"_id\":\"0\",\"_score\":0.70493275}\n"
+ "{\"_index\":\"test_neural_index\",\"_source\":{},\"_id\":\"1\",\"_score\":0.2650575}\n",
result
);

// To allow digits variation from model output, using string contains to match
assertTrue(result.contains("{\"_index\":\"test_neural_index\",\"_source\":{},\"_id\":\"0\",\"_score\":0.70493"));
assertTrue(result.contains("{\"_index\":\"test_neural_index\",\"_source\":{},\"_id\":\"1\",\"_score\":0.26505"));

}

public void testRAGToolWithNeuralQueryAndLLM_withIllegalSourceField_thenGetEmptySource() {
Expand Down
20 changes: 9 additions & 11 deletions src/test/java/org/opensearch/integTest/VectorDBToolIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,11 @@ public void testVectorDBToolInFlowAgent() {
// match exact same text case, doc0 match with higher score
String result1 = executeAgent(agentId, "{\"parameters\": {\"question\": \"hello\"}}");

assertEquals(
"The agent execute response not equal with expected.",
"{\"_index\":\"test_index\",\"_source\":{\"text\":\"hello world\"},\"_id\":\"0\",\"_score\":0.56714886}\n"
+ "{\"_index\":\"test_index\",\"_source\":{\"text\":\"a b\"},\"_id\":\"1\",\"_score\":0.24236833}\n",
result1
// To allow digits variation from model output, using string contains to match
assertTrue(
result1.contains("{\"_index\":\"test_index\",\"_source\":{\"text\":\"hello world\"},\"_id\":\"0\",\"_score\":0.5671488")
);
assertTrue(result1.contains("{\"_index\":\"test_index\",\"_source\":{\"text\":\"a b\"},\"_id\":\"1\",\"_score\":0.2423683"));

// if blank input, call onFailure and get exception
Exception exception = assertThrows(ResponseException.class, () -> executeAgent(agentId, "{\"parameters\": {\"question\": \"\"}}"));
Expand All @@ -164,12 +163,11 @@ public void testVectorDBToolInFlowAgent() {
public void testVectorDBToolInFlowAgent_withIllegalSourceField_thenGetEmptySource() {
String agentId = createAgent(registerAgentRequestBody.replace("text", "text2"));
String result = executeAgent(agentId, "{\"parameters\": {\"question\": \"a\"}}");
assertEquals(
"The agent execute response not equal with expected.",
"{\"_index\":\"test_index\",\"_source\":{},\"_id\":\"0\",\"_score\":0.70493275}\n"
+ "{\"_index\":\"test_index\",\"_source\":{},\"_id\":\"1\",\"_score\":0.2650575}\n",
result
);

// To allow digits variation from model output, using string contains to match
assertTrue(result.contains("{\"_index\":\"test_index\",\"_source\":{},\"_id\":\"0\",\"_score\":0.70493"));
assertTrue(result.contains("{\"_index\":\"test_index\",\"_source\":{},\"_id\":\"1\",\"_score\":0.26505"));

}

public void testVectorDBToolInFlowAgent_withIllegalEmbeddingField_thenThrowException() {
Expand Down

0 comments on commit ebb4182

Please sign in to comment.