Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public class AgentUtils {
public static final String LLM_RESPONSE_FILTER = "llm_response_filter";
public static final String TOOL_RESULT = "tool_result";
public static final String TOOL_CALL_ID = "tool_call_id";
public static final String LLM_INTERFACE_BEDROCK_CONVERSE = "bedrock/converse";
public static final String LLM_INTERFACE_BEDROCK_CONVERSE_CLAUDE = "bedrock/converse/claude";
public static final String LLM_INTERFACE_OPENAI_V1_CHAT_COMPLETIONS = "openai/v1/chat/completions";
public static final String LLM_INTERFACE_BEDROCK_CONVERSE_DEEPSEEK_R1 = "bedrock/converse/deepseek_r1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package org.opensearch.ml.engine.function_calling;

import static org.opensearch.ml.engine.algorithms.agent.AgentUtils.LLM_INTERFACE_BEDROCK_CONVERSE;
import static org.opensearch.ml.engine.algorithms.agent.AgentUtils.LLM_INTERFACE_BEDROCK_CONVERSE_CLAUDE;
import static org.opensearch.ml.engine.algorithms.agent.AgentUtils.LLM_INTERFACE_BEDROCK_CONVERSE_DEEPSEEK_R1;
import static org.opensearch.ml.engine.algorithms.agent.AgentUtils.LLM_INTERFACE_OPENAI_V1_CHAT_COMPLETIONS;
Expand All @@ -21,6 +22,8 @@ public static FunctionCalling create(String llmInterface) {
}

switch (llmInterface.trim().toLowerCase(Locale.ROOT)) {
case LLM_INTERFACE_BEDROCK_CONVERSE:
return new BedrockConverseFunctionCalling();
case LLM_INTERFACE_BEDROCK_CONVERSE_CLAUDE:
return new BedrockConverseFunctionCalling();
case LLM_INTERFACE_OPENAI_V1_CHAT_COMPLETIONS:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static org.opensearch.ml.engine.algorithms.agent.AgentUtils.LLM_FINISH_REASON_PATH;
import static org.opensearch.ml.engine.algorithms.agent.AgentUtils.LLM_FINISH_REASON_TOOL_USE;
import static org.opensearch.ml.engine.algorithms.agent.AgentUtils.LLM_GEN_INPUT;
import static org.opensearch.ml.engine.algorithms.agent.AgentUtils.LLM_INTERFACE_BEDROCK_CONVERSE;
import static org.opensearch.ml.engine.algorithms.agent.AgentUtils.LLM_INTERFACE_BEDROCK_CONVERSE_CLAUDE;
import static org.opensearch.ml.engine.algorithms.agent.AgentUtils.LLM_RESPONSE_EXCLUDE_PATH;
import static org.opensearch.ml.engine.algorithms.agent.AgentUtils.LLM_RESPONSE_FILTER;
Expand Down Expand Up @@ -1898,4 +1899,15 @@ public void testParseLLMOutput_PathNotFoundExceptionWithEmptyToolCalls() {
Assert.assertTrue(output.containsKey(FINAL_ANSWER));
Assert.assertTrue(output.get(FINAL_ANSWER).contains("[]"));
}

@Test
public void testFunctionCallingFactory_BedrockConverseInterface() {
FunctionCalling genericFunctionCalling = FunctionCallingFactory.create(LLM_INTERFACE_BEDROCK_CONVERSE);
FunctionCalling specificFunctionCalling = FunctionCallingFactory.create(LLM_INTERFACE_BEDROCK_CONVERSE_CLAUDE);

Assert.assertNotNull("Generic bedrock/converse interface should create function calling instance", genericFunctionCalling);
Assert.assertNotNull("Specific bedrock/converse/claude interface should create function calling instance", specificFunctionCalling);
Assert.assertEquals("Both interfaces should return the same type",
genericFunctionCalling.getClass(), specificFunctionCalling.getClass());
}
}
Loading