Skip to content

Commit b970740

Browse files
Removed whitespace
1 parent 91ba977 commit b970740

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

orchestration/src/main/java/com/sap/ai/sdk/orchestration/spring/OrchestrationChatModel.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import javax.annotation.Nonnull;
2121
import lombok.extern.slf4j.Slf4j;
2222
import lombok.val;
23+
import org.springframework.ai.chat.messages.AssistantMessage.ToolCall;
2324
import org.springframework.ai.chat.messages.Message;
2425
import org.springframework.ai.chat.messages.ToolResponseMessage;
2526
import org.springframework.ai.chat.model.ChatModel;
@@ -138,15 +139,7 @@ private static com.sap.ai.sdk.orchestration.Message[] toOrchestrationMessages(
138139
if (springToolCalls != null) {
139140
final List<ResponseMessageToolCall> sdkToolCalls =
140141
springToolCalls.stream()
141-
.map(
142-
toolCall ->
143-
ResponseMessageToolCall.create()
144-
.id(toolCall.id())
145-
.type(FUNCTION)
146-
.function(
147-
ResponseMessageToolCallFunction.create()
148-
.name(toolCall.name())
149-
.arguments(toolCall.arguments())))
142+
.map(OrchestrationChatModel::toOrchestrationToolCall)
150143
.toList();
151144
yield List.of(new AssistantMessage(sdkToolCalls));
152145
}
@@ -165,4 +158,15 @@ private static com.sap.ai.sdk.orchestration.Message[] toOrchestrationMessages(
165158
.flatMap(List::stream)
166159
.toArray(com.sap.ai.sdk.orchestration.Message[]::new);
167160
}
161+
162+
@Nonnull
163+
private static ResponseMessageToolCall toOrchestrationToolCall(@Nonnull final ToolCall toolCall) {
164+
return ResponseMessageToolCall.create()
165+
.id(toolCall.id())
166+
.type(FUNCTION)
167+
.function(
168+
ResponseMessageToolCallFunction.create()
169+
.name(toolCall.name())
170+
.arguments(toolCall.arguments()));
171+
}
168172
}

orchestration/src/main/java/com/sap/ai/sdk/orchestration/spring/OrchestrationChatOptions.java

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@
3737
*/
3838
@Beta
3939
@Data
40-
@Getter(AccessLevel.PUBLIC)
4140
public class OrchestrationChatOptions implements ToolCallingChatOptions {
4241

43-
@Getter(AccessLevel.NONE)
4442
private static final ObjectMapper JACKSON = getOrchestrationObjectMapper();
4543

4644
@Nonnull private OrchestrationModuleConfig config;
@@ -203,23 +201,21 @@ public void setFunctionCallbacks(@Nonnull final List<FunctionCallback> toolCallb
203201
final Template template =
204202
Objects.requireNonNullElse(
205203
(Template) config.getTemplateConfig(), Template.create().template());
206-
val tools =
207-
toolCallbacks.stream()
208-
.map(
209-
functionCallback ->
210-
ChatCompletionTool.create()
211-
.type(TypeEnum.FUNCTION)
212-
.function(
213-
FunctionObject.create()
214-
.name(functionCallback.getName())
215-
.description(functionCallback.getDescription())
216-
.parameters(
217-
ModelOptionsUtils.jsonToMap(
218-
functionCallback.getInputTypeSchema()))))
219-
.toList();
204+
val tools = toolCallbacks.stream().map(OrchestrationChatOptions::toOrchestrationTool).toList();
220205
config = config.withTemplateConfig(template.tools(tools));
221206
}
222207

208+
private static ChatCompletionTool toOrchestrationTool(
209+
@Nonnull final FunctionCallback functionCallback) {
210+
return ChatCompletionTool.create()
211+
.type(TypeEnum.FUNCTION)
212+
.function(
213+
FunctionObject.create()
214+
.name(functionCallback.getName())
215+
.description(functionCallback.getDescription())
216+
.parameters(ModelOptionsUtils.jsonToMap(functionCallback.getInputTypeSchema())));
217+
}
218+
223219
@Override
224220
@Nullable
225221
public Boolean isInternalToolExecutionEnabled() {

0 commit comments

Comments
 (0)