Skip to content

Commit 219b12d

Browse files
committed
Merging changes from main
1 parent b956afb commit 219b12d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+825
-898
lines changed

orchestration/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
34
<modelVersion>4.0.0</modelVersion>
45
<parent>
56
<groupId>com.sap.ai.sdk</groupId>

orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationClient.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,20 @@ public OrchestrationClient(@Nonnull final AiCoreDeployment deployment) {
6969
this.deployment = () -> deployment;
7070
}
7171

72+
/**
73+
* Convert the given prompt and config into a low-level request data object. The data object
74+
* allows for further customization before sending the request.
75+
*
76+
* @param prompt The {@link OrchestrationPrompt} to generate a completion for.
77+
* @param config The {@link OrchestrationConfig } configuration to use for the completion.
78+
* @return The low-level request data object to send to orchestration.
79+
*/
80+
@Nonnull
81+
public static CompletionPostRequest toCompletionPostRequest(
82+
@Nonnull final OrchestrationPrompt prompt, @Nonnull final OrchestrationModuleConfig config) {
83+
return ConfigToRequestTransformer.toCompletionPostRequest(prompt, config);
84+
}
85+
7286
/**
7387
* Generate a completion for the given prompt.
7488
*
@@ -121,20 +135,6 @@ public CompletionPostResponse executeRequest(@Nonnull final CompletionPostReques
121135
return executeRequest(postRequest);
122136
}
123137

124-
/**
125-
* Convert the given prompt and config into a low-level request data object. The data object
126-
* allows for further customization before sending the request.
127-
*
128-
* @param prompt The {@link OrchestrationPrompt} to generate a completion for.
129-
* @param config The {@link OrchestrationConfig } configuration to use for the completion.
130-
* @return The low-level request data object to send to orchestration.
131-
*/
132-
@Nonnull
133-
public static CompletionPostRequest toCompletionPostRequest(
134-
@Nonnull final OrchestrationPrompt prompt, @Nonnull final OrchestrationModuleConfig config) {
135-
return ConfigToRequestTransformer.toCompletionPostRequest(prompt, config);
136-
}
137-
138138
@SuppressWarnings("UnstableApiUsage")
139139
@Nonnull
140140
CompletionPostResponse executeRequest(@Nonnull final BasicClassicHttpRequest request) {

orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationResponseHandler.java

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -23,44 +23,6 @@
2323
class OrchestrationResponseHandler<T> implements HttpClientResponseHandler<T> {
2424
@Nonnull private final Class<T> responseType;
2525

26-
/**
27-
* Processes a {@link ClassicHttpResponse} and returns some value corresponding to that response.
28-
*
29-
* @param response The response to process
30-
* @return A model class instantiated from the response
31-
* @throws OrchestrationClientException in case of a problem or the connection was aborted
32-
*/
33-
@Override
34-
public T handleResponse(@Nonnull final ClassicHttpResponse response)
35-
throws OrchestrationClientException {
36-
if (response.getCode() >= 300) {
37-
buildExceptionAndThrow(response);
38-
}
39-
val result = parseResponse(response);
40-
log.debug("Received the following response from orchestration service: {}", result);
41-
return result;
42-
}
43-
44-
// The InputStream of the HTTP entity is closed by EntityUtils.toString
45-
@SuppressWarnings("PMD.CloseResource")
46-
@Nonnull
47-
private T parseResponse(@Nonnull final ClassicHttpResponse response)
48-
throws OrchestrationClientException {
49-
final HttpEntity responseEntity = response.getEntity();
50-
if (responseEntity == null) {
51-
throw new OrchestrationClientException("Response from Orchestration service was empty.");
52-
}
53-
val content = getContent(responseEntity);
54-
log.debug("Parsing response from JSON response: {}", content);
55-
try {
56-
return JACKSON.readValue(content, responseType);
57-
} catch (final JsonProcessingException e) {
58-
log.error("Failed to parse the following response from orchestration service: {}", content);
59-
throw new OrchestrationClientException(
60-
"Failed to parse response from orchestration service", e);
61-
}
62-
}
63-
6426
@Nonnull
6527
private static String getContent(@Nonnull final HttpEntity entity) {
6628
try {
@@ -123,4 +85,42 @@ static void parseErrorAndThrow(
12385
"%s and error message: '%s'"
12486
.formatted(baseException.getMessage(), maybeError.get().getMessage()));
12587
}
88+
89+
/**
90+
* Processes a {@link ClassicHttpResponse} and returns some value corresponding to that response.
91+
*
92+
* @param response The response to process
93+
* @return A model class instantiated from the response
94+
* @throws OrchestrationClientException in case of a problem or the connection was aborted
95+
*/
96+
@Override
97+
public T handleResponse(@Nonnull final ClassicHttpResponse response)
98+
throws OrchestrationClientException {
99+
if (response.getCode() >= 300) {
100+
buildExceptionAndThrow(response);
101+
}
102+
val result = parseResponse(response);
103+
log.debug("Received the following response from orchestration service: {}", result);
104+
return result;
105+
}
106+
107+
// The InputStream of the HTTP entity is closed by EntityUtils.toString
108+
@SuppressWarnings("PMD.CloseResource")
109+
@Nonnull
110+
private T parseResponse(@Nonnull final ClassicHttpResponse response)
111+
throws OrchestrationClientException {
112+
final HttpEntity responseEntity = response.getEntity();
113+
if (responseEntity == null) {
114+
throw new OrchestrationClientException("Response from Orchestration service was empty.");
115+
}
116+
val content = getContent(responseEntity);
117+
log.debug("Parsing response from JSON response: {}", content);
118+
try {
119+
return JACKSON.readValue(content, responseType);
120+
} catch (final JsonProcessingException e) {
121+
log.error("Failed to parse the following response from orchestration service: {}", content);
122+
throw new OrchestrationClientException(
123+
"Failed to parse response from orchestration service", e);
124+
}
125+
}
126126
}

orchestration/src/main/java/com/sap/ai/sdk/orchestration/client/model/AzureContentSafety.java

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,21 @@
3030
comments = "Generator version: 7.9.0")
3131
public class AzureContentSafety {
3232
public static final String JSON_PROPERTY_HATE = "Hate";
33-
private AzureThreshold hate;
34-
3533
public static final String JSON_PROPERTY_SELF_HARM = "SelfHarm";
36-
private AzureThreshold selfHarm;
37-
3834
public static final String JSON_PROPERTY_SEXUAL = "Sexual";
39-
private AzureThreshold sexual;
40-
4135
public static final String JSON_PROPERTY_VIOLENCE = "Violence";
36+
private AzureThreshold hate;
37+
private AzureThreshold selfHarm;
38+
private AzureThreshold sexual;
4239
private AzureThreshold violence;
4340

4441
public AzureContentSafety() {}
4542

43+
/** Create a builder with no initialized field. */
44+
public static AzureContentSafety.Builder builder() {
45+
return new AzureContentSafety.Builder();
46+
}
47+
4648
public AzureContentSafety hate(AzureThreshold hate) {
4749

4850
this.hate = hate;
@@ -181,6 +183,15 @@ private String toIndentedString(Object o) {
181183
return o.toString().replace("\n", "\n ");
182184
}
183185

186+
/** Create a builder with a shallow copy of this instance. */
187+
public AzureContentSafety.Builder toBuilder() {
188+
return new AzureContentSafety.Builder()
189+
.hate(getHate())
190+
.selfHarm(getSelfHarm())
191+
.sexual(getSexual())
192+
.violence(getViolence());
193+
}
194+
184195
public static class Builder {
185196

186197
private AzureContentSafety instance;
@@ -232,18 +243,4 @@ public String toString() {
232243
return getClass() + "=(" + instance + ")";
233244
}
234245
}
235-
236-
/** Create a builder with no initialized field. */
237-
public static AzureContentSafety.Builder builder() {
238-
return new AzureContentSafety.Builder();
239-
}
240-
241-
/** Create a builder with a shallow copy of this instance. */
242-
public AzureContentSafety.Builder toBuilder() {
243-
return new AzureContentSafety.Builder()
244-
.hate(getHate())
245-
.selfHarm(getSelfHarm())
246-
.sexual(getSexual())
247-
.violence(getViolence());
248-
}
249246
}

orchestration/src/main/java/com/sap/ai/sdk/orchestration/client/model/AzureContentSafetyFilterConfig.java

Lines changed: 44 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -29,47 +29,17 @@
2929
date = "2024-11-08T18:02:22.585601+01:00[Europe/Berlin]",
3030
comments = "Generator version: 7.9.0")
3131
public class AzureContentSafetyFilterConfig implements FilterConfig {
32-
/** String represents name of the filter provider */
33-
public enum TypeEnum {
34-
AZURE_CONTENT_SAFETY("azure_content_safety"),
35-
36-
UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api");
37-
38-
private String value;
39-
40-
TypeEnum(String value) {
41-
this.value = value;
42-
}
43-
44-
@JsonValue
45-
public String getValue() {
46-
return value;
47-
}
48-
49-
@Override
50-
public String toString() {
51-
return String.valueOf(value);
52-
}
53-
54-
@JsonCreator
55-
public static TypeEnum fromValue(String value) {
56-
for (TypeEnum b : TypeEnum.values()) {
57-
if (b.value.equals(value)) {
58-
return b;
59-
}
60-
}
61-
return UNKNOWN_DEFAULT_OPEN_API;
62-
}
63-
}
64-
6532
public static final String JSON_PROPERTY_TYPE = "type";
66-
private TypeEnum type;
67-
6833
public static final String JSON_PROPERTY_CONFIG = "config";
34+
private TypeEnum type;
6935
private AzureContentSafety config;
70-
7136
public AzureContentSafetyFilterConfig() {}
7237

38+
/** Create a builder with no initialized field. */
39+
public static AzureContentSafetyFilterConfig.Builder builder() {
40+
return new AzureContentSafetyFilterConfig.Builder();
41+
}
42+
7343
public AzureContentSafetyFilterConfig type(TypeEnum type) {
7444

7545
this.type = type;
@@ -157,6 +127,44 @@ private String toIndentedString(Object o) {
157127
return o.toString().replace("\n", "\n ");
158128
}
159129

130+
/** Create a builder with a shallow copy of this instance. */
131+
public AzureContentSafetyFilterConfig.Builder toBuilder() {
132+
return new AzureContentSafetyFilterConfig.Builder().type(getType()).config(getConfig());
133+
}
134+
135+
/** String represents name of the filter provider */
136+
public enum TypeEnum {
137+
AZURE_CONTENT_SAFETY("azure_content_safety"),
138+
139+
UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api");
140+
141+
private String value;
142+
143+
TypeEnum(String value) {
144+
this.value = value;
145+
}
146+
147+
@JsonCreator
148+
public static TypeEnum fromValue(String value) {
149+
for (TypeEnum b : TypeEnum.values()) {
150+
if (b.value.equals(value)) {
151+
return b;
152+
}
153+
}
154+
return UNKNOWN_DEFAULT_OPEN_API;
155+
}
156+
157+
@JsonValue
158+
public String getValue() {
159+
return value;
160+
}
161+
162+
@Override
163+
public String toString() {
164+
return String.valueOf(value);
165+
}
166+
}
167+
160168
public static class Builder {
161169

162170
private AzureContentSafetyFilterConfig instance;
@@ -198,14 +206,4 @@ public String toString() {
198206
return getClass() + "=(" + instance + ")";
199207
}
200208
}
201-
202-
/** Create a builder with no initialized field. */
203-
public static AzureContentSafetyFilterConfig.Builder builder() {
204-
return new AzureContentSafetyFilterConfig.Builder();
205-
}
206-
207-
/** Create a builder with a shallow copy of this instance. */
208-
public AzureContentSafetyFilterConfig.Builder toBuilder() {
209-
return new AzureContentSafetyFilterConfig.Builder().type(getType()).config(getConfig());
210-
}
211209
}

orchestration/src/main/java/com/sap/ai/sdk/orchestration/client/model/AzureThreshold.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,6 @@ public enum AzureThreshold {
3636
this.value = value;
3737
}
3838

39-
@JsonValue
40-
public Integer getValue() {
41-
return value;
42-
}
43-
44-
@Override
45-
public String toString() {
46-
return String.valueOf(value);
47-
}
48-
4939
@JsonCreator
5040
public static AzureThreshold fromValue(Integer value) {
5141
for (AzureThreshold b : AzureThreshold.values()) {
@@ -55,4 +45,14 @@ public static AzureThreshold fromValue(Integer value) {
5545
}
5646
return NUMBER_unknown_default_open_api;
5747
}
48+
49+
@JsonValue
50+
public Integer getValue() {
51+
return value;
52+
}
53+
54+
@Override
55+
public String toString() {
56+
return String.valueOf(value);
57+
}
5858
}

orchestration/src/main/java/com/sap/ai/sdk/orchestration/client/model/ChatDelta.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@
2525
comments = "Generator version: 7.9.0")
2626
public class ChatDelta {
2727
public static final String JSON_PROPERTY_ROLE = "role";
28-
private String role;
29-
3028
public static final String JSON_PROPERTY_CONTENT = "content";
29+
private String role;
3130
private String content = "";
3231

3332
public ChatDelta() {}
3433

34+
/** Create a builder with no initialized field. */
35+
public static ChatDelta.Builder builder() {
36+
return new ChatDelta.Builder();
37+
}
38+
3539
public ChatDelta role(String role) {
3640

3741
this.role = role;
@@ -118,6 +122,11 @@ private String toIndentedString(Object o) {
118122
return o.toString().replace("\n", "\n ");
119123
}
120124

125+
/** Create a builder with a shallow copy of this instance. */
126+
public ChatDelta.Builder toBuilder() {
127+
return new ChatDelta.Builder().role(getRole()).content(getContent());
128+
}
129+
121130
public static class Builder {
122131

123132
private ChatDelta instance;
@@ -159,14 +168,4 @@ public String toString() {
159168
return getClass() + "=(" + instance + ")";
160169
}
161170
}
162-
163-
/** Create a builder with no initialized field. */
164-
public static ChatDelta.Builder builder() {
165-
return new ChatDelta.Builder();
166-
}
167-
168-
/** Create a builder with a shallow copy of this instance. */
169-
public ChatDelta.Builder toBuilder() {
170-
return new ChatDelta.Builder().role(getRole()).content(getContent());
171-
}
172171
}

0 commit comments

Comments
 (0)