Skip to content

Commit 3917652

Browse files
committed
fix failure ITs and syntax error in CI workflow
Signed-off-by: zane-neo <zaniu@amazon.com>
1 parent 22a2252 commit 3917652

File tree

9 files changed

+27
-27
lines changed

9 files changed

+27
-27
lines changed

.github/workflows/CI-workflow.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
echo "::add-mask::$COHERE_KEY" &&
8585
echo "build and run tests" && ./gradlew build -x spotlessJava &&
8686
echo "Publish to Maven Local" && ./gradlew publishToMavenLocal -x spotlessJava &&
87-
echo "Multi Nodes Integration Testing" && ./gradlew integTest -PnumNodes=3 -x spotlessJava
87+
echo "Multi Nodes Integration Testing" && ./gradlew integTest -PnumNodes=3 -x spotlessJava &&
8888
echo "Run Jacoco test coverage" && && ./gradlew jacocoTestReport && cp -v plugin/build/reports/jacoco/test/jacocoTestReport.xml ./jacocoTestReport.xml'
8989
plugin=`basename $(ls plugin/build/distributions/*.zip)`
9090
echo $plugin

common/src/test/java/org/opensearch/ml/common/transport/agent/MLAgentGetResponseTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void setUp() {
4141
.name("test_agent")
4242
.appType("test_app")
4343
.type(MLAgentType.FLOW.name())
44-
.tools(Arrays.asList(MLToolSpec.builder().type("CatIndexTool").build()))
44+
.tools(Arrays.asList(MLToolSpec.builder().type("ListIndexTool").build()))
4545
.build();
4646
}
4747

common/src/test/java/org/opensearch/ml/common/transport/agent/MLRegisterAgentRequestTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void setUp() {
3535
.name("test_agent")
3636
.appType("test_app")
3737
.type("flow")
38-
.tools(Arrays.asList(MLToolSpec.builder().type("CatIndexTool").build()))
38+
.tools(Arrays.asList(MLToolSpec.builder().type("ListIndexTool").build()))
3939
.build();
4040
}
4141

docs/tutorials/agent_framework/build_your_own_chatbot.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ POST _plugins/_ml/agents/_register
255255
}
256256
},
257257
{
258-
"type": "CatIndexTool",
258+
"type": "ListIndexTool",
259259
"description": "Use this tool to get OpenSearch index information: (health, status, index, uuid, primary count, replica count, docs.count, docs.deleted, store.size, primary.store.size). \nIt takes 2 optional arguments named `index` which is a comma-delimited list of one or more indices to get information from (default is an empty list meaning all indices), and `local` which means whether to return information from the local node only instead of the cluster manager node (default is false)."
260260
},
261261
{
@@ -287,14 +287,14 @@ Tips:
287287
2. Provide a detailed tool description to clarify what the tool can do.
288288
3. Specify the tool to use in the LLM question, for example, `Can you use the PPLTool to query index opensearch_dashboards_sample_data_ecommerce to calculate how many orders there were during last week?`
289289
4. Specify the tool to use when executing an agent,
290-
for example, tell the agent to only use the `PPLTool` and `CatIndexTool` in the current request.
290+
for example, tell the agent to only use the `PPLTool` and `ListIndexTool` in the current request.
291291
```
292292
POST _plugins/_ml/agents/your_agent_id/_execute
293293
{
294294
"parameters": {
295295
"question": "Can you query with index opensearch_dashboards_sample_data_ecommerce to calculate how many orders in last week?",
296296
"verbose": false,
297-
"selected_tools": ["PPLTool", "CatIndexTool"]
297+
"selected_tools": ["PPLTool", "ListIndexTool"]
298298
}
299299
}
300300
```

ml-algorithms/src/test/java/org/opensearch/ml/engine/algorithms/agent/AgentUtilsTest.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -397,9 +397,9 @@ public void testExtractModelResponseJsonWithInvalidModelOutput() {
397397
@Test
398398
public void testExtractModelResponseJsonWithValidModelOutput() {
399399
String text =
400-
"This is the model response\n```json\n{\"thought\":\"use CatIndexTool to get index first\",\"action\":\"CatIndexTool\"} \n``` other content";
400+
"This is the model response\n```json\n{\"thought\":\"use ListIndexTool to get index first\",\"action\":\"ListIndexTool\"} \n``` other content";
401401
String responseJson = AgentUtils.extractModelResponseJson(text);
402-
assertEquals("{\"thought\":\"use CatIndexTool to get index first\",\"action\":\"CatIndexTool\"}", responseJson);
402+
assertEquals("{\"thought\":\"use ListIndexTool to get index first\",\"action\":\"ListIndexTool\"}", responseJson);
403403
}
404404

405405
@Test
@@ -477,7 +477,7 @@ public void testExtractMethods_FinalAnswer() {
477477

478478
@Test
479479
public void testParseLLMOutput() {
480-
Set<String> tools = Set.of("VectorDBTool", "CatIndexTool");
480+
Set<String> tools = Set.of("VectorDBTool", "ListIndexTool");
481481
for (Map.Entry<String, Map<String, String>> entry : llmResponseExpectedParseResults.entrySet()) {
482482
ModelTensorOutput modelTensoOutput = ModelTensorOutput
483483
.builder()
@@ -502,7 +502,7 @@ public void testParseLLMOutput() {
502502

503503
@Test
504504
public void testParseLLMOutput_MultipleFields() {
505-
Set<String> tools = Set.of("VectorDBTool", "CatIndexTool");
505+
Set<String> tools = Set.of("VectorDBTool", "ListIndexTool");
506506
String thought = "Let me run VectorDBTool to get more information";
507507
String toolName = "vectordbtool";
508508
ModelTensorOutput modelTensoOutput = ModelTensorOutput
@@ -536,7 +536,7 @@ public void testParseLLMOutput_MultipleFields() {
536536

537537
@Test
538538
public void testParseLLMOutput_MultipleFields_NoActionAndFinalAnswer() {
539-
Set<String> tools = Set.of("VectorDBTool", "CatIndexTool");
539+
Set<String> tools = Set.of("VectorDBTool", "ListIndexTool");
540540
String key1 = "dummy key1";
541541
String value1 = "dummy value1";
542542
String key2 = "dummy key2";
@@ -570,7 +570,7 @@ public void testParseLLMOutput_MultipleFields_NoActionAndFinalAnswer() {
570570

571571
@Test
572572
public void testParseLLMOutput_OneFields_NoActionAndFinalAnswer() {
573-
Set<String> tools = Set.of("VectorDBTool", "CatIndexTool");
573+
Set<String> tools = Set.of("VectorDBTool", "ListIndexTool");
574574
String thought = "Let me run VectorDBTool to get more information";
575575
ModelTensorOutput modelTensoOutput = ModelTensorOutput
576576
.builder()

plugin/src/test/java/org/opensearch/ml/rest/MLCommonsRestTestCase.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -804,19 +804,19 @@ public void deleteAgent(RestClient client, String agentId, Consumer<Map<String,
804804
verifyResponse(function, response);
805805
}
806806

807-
public MLAgent createCatIndexToolMLAgent() {
808-
MLToolSpec catIndexTool = MLToolSpec
807+
public MLAgent createListIndexToolMLAgent() {
808+
MLToolSpec listIndexTool = MLToolSpec
809809
.builder()
810-
.type("CatIndexTool")
811-
.name("DemoCatIndexTool")
810+
.type("ListIndexTool")
811+
.name("DemoListIndexTool")
812812
.parameters(Map.of("input", "${parameters.question}"))
813813
.build();
814814
return MLAgent
815815
.builder()
816816
.name("Test_Agent_For_CatIndex_tool")
817817
.type("flow")
818-
.description("this is a test agent for the CatIndexTool")
819-
.tools(List.of(catIndexTool))
818+
.description("this is a test agent for the ListIndexTool")
819+
.tools(List.of(listIndexTool))
820820
.build();
821821
}
822822

plugin/src/test/java/org/opensearch/ml/rest/RestMLFlowAgentIT.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ public void deleteIndices() throws IOException {
2929
deleteIndexWithAdminClient(irisIndex);
3030
}
3131

32-
public void testAgentCatIndexTool() throws IOException {
33-
// Register agent with CatIndexTool.
34-
Response response = registerAgentWithCatIndexTool();
32+
public void testAgentListIndexTool() throws IOException {
33+
// Register agent with ListIndexTool.
34+
Response response = registerAgentWithListIndexTool();
3535
Map responseMap = parseResponseToMap(response);
3636
String agentId = (String) responseMap.get("agent_id");
3737
assertNotNull(agentId);
3838
assertEquals(20, agentId.length());
3939

4040
// Execute agent.
41-
response = executeAgentCatIndexTool(agentId);
41+
response = executeAgentListIndexTool(agentId);
4242
responseMap = parseResponseToMap(response);
4343
List responseList = (List) responseMap.get("inference_results");
4444
responseMap = (Map) responseList.get(0);
@@ -71,11 +71,11 @@ public void testAgentSearchIndexTool() throws IOException {
7171
assertTrue(result.contains("\"_source\":{\"petal_length_in_cm\""));
7272
}
7373

74-
public static Response registerAgentWithCatIndexTool() throws IOException {
74+
public static Response registerAgentWithListIndexTool() throws IOException {
7575
String registerAgentEntity = "{\n"
7676
+ " \"name\": \"Test_Agent_For_CatIndex_tool\",\n"
7777
+ " \"type\": \"flow\",\n"
78-
+ " \"description\": \"this is a test agent for the CatIndexTool\",\n"
78+
+ " \"description\": \"this is a test agent for the ListIndexTool\",\n"
7979
+ " \"tools\": [\n"
8080
+ " {\n"
8181
+ " \"type\": \"ListIndexTool\",\n"
@@ -105,7 +105,7 @@ public static Response registerAgentWithSearchIndexTool() throws IOException {
105105
.makeRequest(client(), "POST", "/_plugins/_ml/agents/_register", null, TestHelper.toHttpEntity(registerAgentEntity), null);
106106
}
107107

108-
public static Response executeAgentCatIndexTool(String agentId) throws IOException {
108+
public static Response executeAgentListIndexTool(String agentId) throws IOException {
109109
String question = "\"How many indices do I have?\"";
110110
return executeAgent(agentId, Map.of("question", question));
111111
}

plugin/src/test/java/org/opensearch/ml/rest/SecureMLRestIT.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public void setup() throws IOException, ParseException {
159159
});
160160
mlRegisterModelInput = createRegisterModelInput(modelGroupId);
161161

162-
mlAgent = createCatIndexToolMLAgent();
162+
mlAgent = createListIndexToolMLAgent();
163163
}
164164

165165
@After

plugin/src/test/java/org/opensearch/ml/utils/TestHelper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ public static RestRequest getExecuteAgentRestRequest() {
385385
params.put(PARAMETER_AGENT_ID, "test_agent_id");
386386
final String requestContent = "{\"name\":\"Test_Agent_For_RAG\",\"type\":\"flow\","
387387
+ "\"description\":\"this is a test agent\",\"app_type\":\"my app\","
388-
+ "\"tools\":[{\"type\":\"CatIndexTool\",\"name\":\"CatIndexTool\","
388+
+ "\"tools\":[{\"type\":\"ListIndexTool\",\"name\":\"ListIndexTool\","
389389
+ "\"description\":\"Use this tool to get OpenSearch index information: "
390390
+ "(health, status, index, uuid, primary count, replica count, docs.count, docs.deleted, "
391391
+ "store.size, primary.store.size).\",\"include_output_in_agent_response\":true}]}";

0 commit comments

Comments
 (0)