Skip to content

Commit 23f625d

Browse files
authored
function calling bug fix (#3692)
Signed-off-by: Jing Zhang <[email protected]>
1 parent 13cf2de commit 23f625d

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

ml-algorithms/src/main/java/org/opensearch/ml/engine/function_calling/BedrockConverseDeepseekR1FunctionCalling.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ public List<Map<String, String>> handle(ModelTensorOutput tmpModelTensorOutput,
5353
return output;
5454
}
5555
for (Object call : toolCalls) {
56-
String toolName = JsonPath.read(call, parameters.get(NAME));
57-
String toolInput = StringUtils.toJson(JsonPath.read(call, parameters.get(INPUT)));
58-
String toolCallId = JsonPath.read(call, parameters.get(ID_PATH));
56+
String toolName = JsonPath.read(call, NAME);
57+
String toolInput = StringUtils.toJson(JsonPath.read(call, INPUT));
58+
String toolCallId = JsonPath.read(call, ID_PATH);
5959
output.add(Map.of("tool_name", toolName, "tool_input", toolInput, "tool_call_id", toolCallId));
6060
}
6161
return output;

ml-algorithms/src/main/java/org/opensearch/ml/engine/function_calling/BedrockConverseFunctionCalling.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ public List<Map<String, String>> handle(ModelTensorOutput tmpModelTensorOutput,
5353
return output;
5454
}
5555
for (Object call : toolCalls) {
56-
String toolName = JsonPath.read(call, parameters.get(NAME));
57-
String toolInput = StringUtils.toJson(JsonPath.read(call, parameters.get(INPUT)));
58-
String toolCallId = JsonPath.read(call, parameters.get(ID_PATH));
56+
String toolName = JsonPath.read(call, NAME);
57+
String toolInput = StringUtils.toJson(JsonPath.read(call, INPUT));
58+
String toolCallId = JsonPath.read(call, ID_PATH);
5959
output.add(Map.of("tool_name", toolName, "tool_input", toolInput, "tool_call_id", toolCallId));
6060
}
6161
return output;

ml-algorithms/src/main/java/org/opensearch/ml/engine/function_calling/FunctionCallingFactory.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import org.opensearch.ml.common.exception.MLException;
1111

1212
public class FunctionCallingFactory {
13-
public FunctionCalling create(String llmInterface) {
13+
public static FunctionCalling create(String llmInterface) {
1414
if (StringUtils.isBlank(llmInterface)) {
1515
return null;
1616
}
@@ -21,7 +21,7 @@ public FunctionCalling create(String llmInterface) {
2121
case LLM_INTERFACE_OPENAI_V1_CHAT_COMPLETIONS:
2222
return new OpenaiV1ChatCompletionsFunctionCalling();
2323
case LLM_INTERFACE_BEDROCK_CONVERSE_DEEPSEEK_R1:
24-
return null;
24+
return new BedrockConverseDeepseekR1FunctionCalling();
2525
default:
2626
throw new MLException(String.format("Unsupported llm interface: {}.", llmInterface));
2727
}

ml-algorithms/src/main/java/org/opensearch/ml/engine/function_calling/OpenaiV1ChatCompletionsFunctionCalling.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ public List<Map<String, String>> handle(ModelTensorOutput tmpModelTensorOutput,
4949
return output;
5050
}
5151
for (Object call : toolCalls) {
52-
String toolName = JsonPath.read(call, parameters.get(NAME));
53-
String toolInput = StringUtils.toJson(JsonPath.read(call, parameters.get(INPUT)));
54-
String toolCallId = JsonPath.read(call, parameters.get(ID_PATH));
52+
String toolName = JsonPath.read(call, NAME);
53+
String toolInput = StringUtils.toJson(JsonPath.read(call, INPUT));
54+
String toolCallId = JsonPath.read(call, ID_PATH);
5555
output.add(Map.of("tool_name", toolName, "tool_input", toolInput, "tool_call_id", toolCallId));
5656
}
5757
return output;

0 commit comments

Comments
 (0)