Skip to content

Commit 21eaf23

Browse files
committed
Merge branch 'main' into Fixing-OpenAi-AssistantMessage-Bug
2 parents c2939f4 + 8751f95 commit 21eaf23

File tree

15 files changed

+82
-110
lines changed

15 files changed

+82
-110
lines changed

.github/ISSUE_TEMPLATE/bug-report.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@ body:
4646
- Java and Maven version via `mvn --version`: ...
4747
- SAP Cloud SDK for AI version: ...
4848
- Spring Boot or CAP version: ...
49-
- <details><summary>Dependency tree via `mvn dependency:tree`</summary>
50-
51-
```
52-
Dependency tree here
53-
```
54-
</details>
49+
50+
<details><summary>Dependency tree via <code>mvn dependency:tree</code></summary>
51+
52+
```
53+
Dependency tree here
54+
```
55+
</details>
5556
validations:
5657
required: true
5758
- type: textarea

.github/workflows/spec-update.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
required: false
1010
options:
1111
- core
12-
- grounding
12+
- document-grounding
1313
- orchestration
1414
- prompt-registry
1515
default: orchestration
@@ -83,7 +83,7 @@ jobs:
8383
API_URL="$API_BASE_URL/cloudsdk/cloud-sdk-java-tests/contents/aicore.yaml?ref=$REF"
8484
FILE_PATH='core/src/main/resources/spec/aicore.yaml'
8585
;;
86-
grounding)
86+
document-grounding)
8787
API_URL="$API_BASE_URL/AI/rage-proxy-inference/contents/docs/public/business_api_hub/api_hub_merged_spec.yaml?ref=$REF"
8888
FILE_PATH='core-services/document-grounding/src/main/resources/spec/grounding.yaml'
8989
;;

.github/workflows/weekly-spec-update.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
matrix:
1313
file:
1414
- core
15-
- grounding
15+
- document-grounding
1616
- prompt-registry
1717

1818
steps:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ The following table lists the required versions, based on the latest release:
4545
| SAP Cloud SDK | 5.6.0 | latest |
4646
| (optional) CAP Java | 3.0.0 | latest |
4747
| (optional) Spring Boot | 3.0 | latest |
48+
| (optional) Spring AI | 1.0.0 | latest |
4849

4950
See [an example `pom.xml` in our Spring Boot application](sample-code/spring-app/pom.xml).
5051

docs/release_notes.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88

99
### 🔧 Compatibility Notes
1010

11-
-
11+
- The **Spring AI** version has been increased from `1.0.0-M6` to the GA release `1.0.0`.
12+
- The `OrchestrationChatOptions` have been, replacing all references to `FunctionCallback` with `ToolCallback`.
13+
- Please follow the [official Spring AI upgrade guide](https://docs.spring.io/spring-ai/reference/upgrade-notes.html#upgrading-to-1-0-0-RC1) for further details.
14+
- The `@Beta` annotations on all classes related to Spring AI have been removed.
15+
1216

1317
### ✨ New Functionality
1418

foundation-models/openai/pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,12 @@
104104
</dependency>
105105
<dependency>
106106
<groupId>org.springframework.ai</groupId>
107-
<artifactId>spring-ai-core</artifactId>
107+
<artifactId>spring-ai-commons</artifactId>
108+
<optional>true</optional>
109+
</dependency>
110+
<dependency>
111+
<groupId>org.springframework.ai</groupId>
112+
<artifactId>spring-ai-model</artifactId>
108113
<optional>true</optional>
109114
</dependency>
110115
<!-- scope "provided" -->

orchestration/pom.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
</dependency>
6262
<dependency>
6363
<groupId>org.springframework.ai</groupId>
64-
<artifactId>spring-ai-core</artifactId>
64+
<artifactId>spring-ai-model</artifactId>
6565
<optional>true</optional>
6666
</dependency>
6767
<dependency>
@@ -154,6 +154,13 @@
154154
<artifactId>javaparser-core</artifactId>
155155
<scope>test</scope>
156156
</dependency>
157+
<dependency>
158+
<groupId>org.springframework.ai</groupId>
159+
<artifactId>spring-ai-client-chat</artifactId>
160+
<scope>test</scope>
161+
<!-- optional is only set to satisfy our enforcer rule, it doesn't matter for test dependencies -->
162+
<optional>true</optional>
163+
</dependency>
157164
</dependencies>
158165

159166
<profiles>

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import static com.sap.ai.sdk.orchestration.OrchestrationClient.toCompletionPostRequest;
44
import static com.sap.ai.sdk.orchestration.model.MessageToolCall.TypeEnum.FUNCTION;
55

6-
import com.google.common.annotations.Beta;
76
import com.sap.ai.sdk.orchestration.AssistantMessage;
87
import com.sap.ai.sdk.orchestration.OrchestrationChatCompletionDelta;
98
import com.sap.ai.sdk.orchestration.OrchestrationClient;
@@ -34,7 +33,6 @@
3433
*
3534
* @since 1.2.0
3635
*/
37-
@Beta
3836
@Slf4j
3937
public class OrchestrationChatModel implements ChatModel {
4038
@Nonnull private final OrchestrationClient client;

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

Lines changed: 22 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import static com.sap.ai.sdk.orchestration.OrchestrationJacksonConfiguration.getOrchestrationObjectMapper;
99

1010
import com.fasterxml.jackson.databind.ObjectMapper;
11-
import com.google.common.annotations.Beta;
1211
import com.sap.ai.sdk.orchestration.OrchestrationModuleConfig;
1312
import com.sap.ai.sdk.orchestration.model.ChatCompletionTool;
1413
import com.sap.ai.sdk.orchestration.model.ChatCompletionTool.TypeEnum;
@@ -27,30 +26,30 @@
2726
import lombok.val;
2827
import org.springframework.ai.chat.prompt.ChatOptions;
2928
import org.springframework.ai.model.ModelOptionsUtils;
30-
import org.springframework.ai.model.function.FunctionCallback;
3129
import org.springframework.ai.model.tool.ToolCallingChatOptions;
30+
import org.springframework.ai.tool.ToolCallback;
3231

3332
/**
3433
* Configuration to be used for orchestration requests.
3534
*
3635
* @since 1.2.0
3736
*/
38-
@Beta
3937
@Data
4038
public class OrchestrationChatOptions implements ToolCallingChatOptions {
4139

4240
private static final ObjectMapper JACKSON = getOrchestrationObjectMapper();
4341

4442
@Nonnull private OrchestrationModuleConfig config;
4543

46-
private List<FunctionCallback> functionCallbacks;
44+
@Nonnull private List<ToolCallback> toolCallbacks = List.of();
4745

4846
@Getter(AccessLevel.NONE)
47+
@Nullable
4948
private Boolean internalToolExecutionEnabled;
5049

51-
private Set<String> toolNames;
50+
@Nonnull private Set<String> toolNames = Set.of();
5251

53-
private Map<String, Object> toolContext;
52+
@Nonnull private Map<String, Object> toolContext = Map.of();
5453

5554
/**
5655
* Returns the model to use for the chat.
@@ -177,72 +176,37 @@ private <T> T getLlmConfigParam(@Nonnull final String param) {
177176
return ((Map<String, T>) getLlmConfigNonNull().getModelParams()).get(param);
178177
}
179178

180-
@Nonnull
181-
private LLMModuleConfig getLlmConfigNonNull() {
182-
return Objects.requireNonNull(
183-
config.getLlmConfig(),
184-
"LLM config is not set. Please set it: new OrchestrationChatOptions(new OrchestrationModuleConfig().withLlmConfig(...))");
185-
}
186-
187-
@Nonnull
188179
@Override
189-
public List<FunctionCallback> getToolCallbacks() {
190-
return functionCallbacks;
191-
}
192-
193-
@Override
194-
@Deprecated
195-
public void setFunctionCallbacks(@Nonnull final List<FunctionCallback> toolCallbacks) {
196-
setToolCallbacks(toolCallbacks);
197-
}
198-
199-
@Override
200-
public void setToolCallbacks(@Nonnull final List<FunctionCallback> toolCallbacks) {
201-
this.functionCallbacks = toolCallbacks;
180+
public void setToolCallbacks(@Nonnull final List<ToolCallback> toolCallbacks) {
181+
this.toolCallbacks = toolCallbacks;
202182
final Template template =
203183
Objects.requireNonNullElse(
204184
(Template) config.getTemplateConfig(), Template.create().template());
205185
val tools = toolCallbacks.stream().map(OrchestrationChatOptions::toOrchestrationTool).toList();
206186
config = config.withTemplateConfig(template.tools(tools));
207187
}
208188

209-
private static ChatCompletionTool toOrchestrationTool(
210-
@Nonnull final FunctionCallback functionCallback) {
211-
return ChatCompletionTool.create()
212-
.type(TypeEnum.FUNCTION)
213-
.function(
214-
FunctionObject.create()
215-
.name(functionCallback.getName())
216-
.description(functionCallback.getDescription())
217-
.parameters(ModelOptionsUtils.jsonToMap(functionCallback.getInputTypeSchema())));
218-
}
219-
220-
@Override
221189
@Nullable
222-
public Boolean isInternalToolExecutionEnabled() {
190+
@Override
191+
public Boolean getInternalToolExecutionEnabled() {
223192
return this.internalToolExecutionEnabled;
224193
}
225194

226195
@Nonnull
227-
@Override
228-
public Set<String> getFunctions() {
229-
return Set.of();
196+
private LLMModuleConfig getLlmConfigNonNull() {
197+
return Objects.requireNonNull(
198+
config.getLlmConfig(),
199+
"LLM config is not set. Please set it: new OrchestrationChatOptions(new OrchestrationModuleConfig().withLlmConfig(...))");
230200
}
231201

232-
@Override
233-
public void setFunctions(@Nonnull final Set<String> functions) {
234-
// val template =
235-
// Objects.requireNonNullElse(
236-
// (Template) config.getTemplateConfig(), Template.create().template());
237-
// val tools =
238-
// functionNames.stream()
239-
// .map(
240-
// functionName ->
241-
// ChatCompletionTool.create()
242-
// .type(TypeEnum.FUNCTION)
243-
// .function(FunctionObject.create().name(functionName)))
244-
// .toList();
245-
// config = config.withTemplateConfig(template.tools(tools));
246-
throw new UnsupportedOperationException("Not implemented yet");
202+
private static ChatCompletionTool toOrchestrationTool(@Nonnull final ToolCallback toolCallback) {
203+
val toolDef = toolCallback.getToolDefinition();
204+
return ChatCompletionTool.create()
205+
.type(TypeEnum.FUNCTION)
206+
.function(
207+
FunctionObject.create()
208+
.name(toolDef.name())
209+
.description(toolDef.description())
210+
.parameters(ModelOptionsUtils.jsonToMap(toolDef.inputSchema())));
247211
}
248212
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.sap.ai.sdk.orchestration.spring;
22

3-
import com.google.common.annotations.Beta;
43
import com.sap.ai.sdk.orchestration.OrchestrationChatCompletionDelta;
54
import com.sap.ai.sdk.orchestration.model.LLMChoiceStreaming;
65
import com.sap.ai.sdk.orchestration.model.LLMModuleResultStreaming;
@@ -22,7 +21,6 @@
2221
*
2322
* @since 1.2.0
2423
*/
25-
@Beta
2624
@Value
2725
@EqualsAndHashCode(callSuper = true)
2826
public class OrchestrationSpringChatDelta extends ChatResponse {

0 commit comments

Comments
 (0)