Skip to content
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 .github/workflows/CI-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ jobs:
echo "::add-mask::$COHERE_KEY" &&
echo "build and run tests" && ./gradlew build -x spotlessJava &&
echo "Publish to Maven Local" && ./gradlew publishToMavenLocal -x spotlessJava &&
echo "Multi Nodes Integration Testing" && ./gradlew integTest -PnumNodes=3 -x spotlessJava
echo "Run Jacoco test coverage" && && ./gradlew jacocoTestReport && cp -v plugin/build/reports/jacoco/test/jacocoTestReport.xml ./jacocoTestReport.xml'
echo "Multi Nodes Integration Testing" && ./gradlew integTest -PnumNodes=3 -x spotlessJava &&
echo "Run Jacoco test coverage" && ./gradlew jacocoTestReport && cp -v plugin/build/reports/jacoco/test/jacocoTestReport.xml ./jacocoTestReport.xml'
plugin=`basename $(ls plugin/build/distributions/*.zip)`
echo $plugin
mv -v plugin/build/distributions/$plugin ./
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void setUp() {
.name("test_agent")
.appType("test_app")
.type(MLAgentType.FLOW.name())
.tools(Arrays.asList(MLToolSpec.builder().type("CatIndexTool").build()))
.tools(Arrays.asList(MLToolSpec.builder().type("ListIndexTool").build()))
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void setUp() {
.name("test_agent")
.appType("test_app")
.type("flow")
.tools(Arrays.asList(MLToolSpec.builder().type("CatIndexTool").build()))
.tools(Arrays.asList(MLToolSpec.builder().type("ListIndexTool").build()))
.build();
}

Expand Down
6 changes: 3 additions & 3 deletions docs/tutorials/agent_framework/build_your_own_chatbot.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ POST _plugins/_ml/agents/_register
}
},
{
"type": "CatIndexTool",
"type": "ListIndexTool",
"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)."
},
{
Expand Down Expand Up @@ -287,14 +287,14 @@ Tips:
2. Provide a detailed tool description to clarify what the tool can do.
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?`
4. Specify the tool to use when executing an agent,
for example, tell the agent to only use the `PPLTool` and `CatIndexTool` in the current request.
for example, tell the agent to only use the `PPLTool` and `ListIndexTool` in the current request.
```
POST _plugins/_ml/agents/your_agent_id/_execute
{
"parameters": {
"question": "Can you query with index opensearch_dashboards_sample_data_ecommerce to calculate how many orders in last week?",
"verbose": false,
"selected_tools": ["PPLTool", "CatIndexTool"]
"selected_tools": ["PPLTool", "ListIndexTool"]
}
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,9 @@ public void testExtractModelResponseJsonWithInvalidModelOutput() {
@Test
public void testExtractModelResponseJsonWithValidModelOutput() {
String text =
"This is the model response\n```json\n{\"thought\":\"use CatIndexTool to get index first\",\"action\":\"CatIndexTool\"} \n``` other content";
"This is the model response\n```json\n{\"thought\":\"use ListIndexTool to get index first\",\"action\":\"ListIndexTool\"} \n``` other content";
String responseJson = AgentUtils.extractModelResponseJson(text);
assertEquals("{\"thought\":\"use CatIndexTool to get index first\",\"action\":\"CatIndexTool\"}", responseJson);
assertEquals("{\"thought\":\"use ListIndexTool to get index first\",\"action\":\"ListIndexTool\"}", responseJson);
}

@Test
Expand Down Expand Up @@ -477,7 +477,7 @@ public void testExtractMethods_FinalAnswer() {

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

@Test
public void testParseLLMOutput_MultipleFields() {
Set<String> tools = Set.of("VectorDBTool", "CatIndexTool");
Set<String> tools = Set.of("VectorDBTool", "ListIndexTool");
String thought = "Let me run VectorDBTool to get more information";
String toolName = "vectordbtool";
ModelTensorOutput modelTensoOutput = ModelTensorOutput
Expand Down Expand Up @@ -536,7 +536,7 @@ public void testParseLLMOutput_MultipleFields() {

@Test
public void testParseLLMOutput_MultipleFields_NoActionAndFinalAnswer() {
Set<String> tools = Set.of("VectorDBTool", "CatIndexTool");
Set<String> tools = Set.of("VectorDBTool", "ListIndexTool");
String key1 = "dummy key1";
String value1 = "dummy value1";
String key2 = "dummy key2";
Expand Down Expand Up @@ -570,7 +570,7 @@ public void testParseLLMOutput_MultipleFields_NoActionAndFinalAnswer() {

@Test
public void testParseLLMOutput_OneFields_NoActionAndFinalAnswer() {
Set<String> tools = Set.of("VectorDBTool", "CatIndexTool");
Set<String> tools = Set.of("VectorDBTool", "ListIndexTool");
String thought = "Let me run VectorDBTool to get more information";
ModelTensorOutput modelTensoOutput = ModelTensorOutput
.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -804,19 +804,19 @@ public void deleteAgent(RestClient client, String agentId, Consumer<Map<String,
verifyResponse(function, response);
}

public MLAgent createCatIndexToolMLAgent() {
MLToolSpec catIndexTool = MLToolSpec
public MLAgent createListIndexToolMLAgent() {
MLToolSpec listIndexTool = MLToolSpec
.builder()
.type("CatIndexTool")
.name("DemoCatIndexTool")
.type("ListIndexTool")
.name("DemoListIndexTool")
.parameters(Map.of("input", "${parameters.question}"))
.build();
return MLAgent
.builder()
.name("Test_Agent_For_CatIndex_tool")
.type("flow")
.description("this is a test agent for the CatIndexTool")
.tools(List.of(catIndexTool))
.description("this is a test agent for the ListIndexTool")
.tools(List.of(listIndexTool))
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ public void deleteIndices() throws IOException {
deleteIndexWithAdminClient(irisIndex);
}

public void testAgentCatIndexTool() throws IOException {
// Register agent with CatIndexTool.
Response response = registerAgentWithCatIndexTool();
public void testAgentListIndexTool() throws IOException {
// Register agent with ListIndexTool.
Response response = registerAgentWithListIndexTool();
Map responseMap = parseResponseToMap(response);
String agentId = (String) responseMap.get("agent_id");
assertNotNull(agentId);
assertEquals(20, agentId.length());

// Execute agent.
response = executeAgentCatIndexTool(agentId);
response = executeAgentListIndexTool(agentId);
responseMap = parseResponseToMap(response);
List responseList = (List) responseMap.get("inference_results");
responseMap = (Map) responseList.get(0);
Expand Down Expand Up @@ -71,11 +71,11 @@ public void testAgentSearchIndexTool() throws IOException {
assertTrue(result.contains("\"_source\":{\"petal_length_in_cm\""));
}

public static Response registerAgentWithCatIndexTool() throws IOException {
public static Response registerAgentWithListIndexTool() throws IOException {
String registerAgentEntity = "{\n"
+ " \"name\": \"Test_Agent_For_CatIndex_tool\",\n"
+ " \"type\": \"flow\",\n"
+ " \"description\": \"this is a test agent for the CatIndexTool\",\n"
+ " \"description\": \"this is a test agent for the ListIndexTool\",\n"
+ " \"tools\": [\n"
+ " {\n"
+ " \"type\": \"ListIndexTool\",\n"
Expand Down Expand Up @@ -105,7 +105,7 @@ public static Response registerAgentWithSearchIndexTool() throws IOException {
.makeRequest(client(), "POST", "/_plugins/_ml/agents/_register", null, TestHelper.toHttpEntity(registerAgentEntity), null);
}

public static Response executeAgentCatIndexTool(String agentId) throws IOException {
public static Response executeAgentListIndexTool(String agentId) throws IOException {
String question = "\"How many indices do I have?\"";
return executeAgent(agentId, Map.of("question", question));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public void setup() throws IOException, ParseException {
});
mlRegisterModelInput = createRegisterModelInput(modelGroupId);

mlAgent = createCatIndexToolMLAgent();
mlAgent = createListIndexToolMLAgent();
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ public static RestRequest getExecuteAgentRestRequest() {
params.put(PARAMETER_AGENT_ID, "test_agent_id");
final String requestContent = "{\"name\":\"Test_Agent_For_RAG\",\"type\":\"flow\","
+ "\"description\":\"this is a test agent\",\"app_type\":\"my app\","
+ "\"tools\":[{\"type\":\"CatIndexTool\",\"name\":\"CatIndexTool\","
+ "\"tools\":[{\"type\":\"ListIndexTool\",\"name\":\"ListIndexTool\","
+ "\"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).\",\"include_output_in_agent_response\":true}]}";
Expand Down
Loading