Skip to content

Commit 80123b3

Browse files
Use Default Query
Signed-off-by: rithin-pullela-aws <rithinp@amazon.com>
1 parent 19eeb7b commit 80123b3

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

ml-algorithms/src/main/java/org/opensearch/ml/engine/tools/QueryPlanningTool.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ private Parser createParserWithDefaultExtractJson(Map<String, Object> params) {
472472
Map<String, Object> extractJsonConfig = new HashMap<>();
473473
extractJsonConfig.put("type", "extract_json");
474474
extractJsonConfig.put("extract_type", "object"); // Extract JSON objects only
475-
extractJsonConfig.put("default", DEFAULT_SEARCH_TEMPLATE); // Return default search template if no JSON found
475+
extractJsonConfig.put("default", DEFAULT_QUERY); // Return default match all query if no JSON found
476476

477477
// Combine: default extract_json first, then any custom processors
478478
List<Map<String, Object>> combinedProcessorConfigs = new ArrayList<>();

ml-algorithms/src/test/java/org/opensearch/ml/engine/tools/QueryPlanningToolTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
import static org.mockito.Mockito.verify;
2121
import static org.mockito.Mockito.when;
2222
import static org.opensearch.ml.common.utils.StringUtils.gson;
23+
import static org.opensearch.ml.engine.tools.QueryPlanningPromptTemplate.DEFAULT_QUERY;
2324
import static org.opensearch.ml.engine.tools.QueryPlanningPromptTemplate.DEFAULT_QUERY_PLANNING_SYSTEM_PROMPT;
24-
import static org.opensearch.ml.engine.tools.QueryPlanningPromptTemplate.DEFAULT_SEARCH_TEMPLATE;
2525
import static org.opensearch.ml.engine.tools.QueryPlanningTool.DEFAULT_DESCRIPTION;
2626
import static org.opensearch.ml.engine.tools.QueryPlanningTool.INDEX_MAPPING_FIELD;
2727
import static org.opensearch.ml.engine.tools.QueryPlanningTool.INDEX_NAME_FIELD;
@@ -1415,7 +1415,7 @@ public void testFactoryCreatedTool_DefaultExtractJsonParser() {
14151415
// Test case 3: No valid JSON - should return default template
14161416
Object parsedResult3 = outputParser.parse("No JSON here at all");
14171417
String resultNoJson = parsedResult3 instanceof String ? (String) parsedResult3 : gson.toJson(parsedResult3);
1418-
assertEquals(DEFAULT_SEARCH_TEMPLATE, resultNoJson);
1418+
assertEquals(DEFAULT_QUERY, resultNoJson);
14191419
}
14201420

14211421
// Test 2: Create tool from factory with custom processors, verify both default and custom processors work
@@ -1474,7 +1474,7 @@ public void testQueryPlanningTool_WithMockedMLModelTool_EndToEnd() {
14741474
Map<String, Object> extractJsonConfig = new HashMap<>();
14751475
extractJsonConfig.put("type", "extract_json");
14761476
extractJsonConfig.put("extract_type", "object");
1477-
extractJsonConfig.put("default", DEFAULT_SEARCH_TEMPLATE);
1477+
extractJsonConfig.put("default", DEFAULT_QUERY);
14781478

14791479
// Set the parser on the tool
14801480
tool.setOutputParser(ToolParser.createProcessingParser(null, List.of(extractJsonConfig)));

0 commit comments

Comments
 (0)