Skip to content

Commit 5a14d4f

Browse files
authored
feat: [OpenAI] Generated model classes for OpenAI client (#322)
* Full openapi generated code for openai module * Exclude test cov and suppress todos in generated code * Fix rearrangement of code * Movel all generated models from model2 to generated/model * Add missing option in generated enums with java doc - adapt `fromValue` method to not throw --------- Co-authored-by: Roshin Rajan Panackal <[email protected]>
1 parent 46fe11d commit 5a14d4f

File tree

80 files changed

+18447
-0
lines changed

Some content is hidden

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

80 files changed

+18447
-0
lines changed

.pipeline/checkstyle-suppressions.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
<!-- Suppress generated clients -->
99
<suppress files="[/\\]core[/\\]client[/\\]" checks=".*"/>
1010
<suppress files="[/\\]core[/\\]model[/\\]" checks=".*"/>
11+
<suppress files="[/\\]openai[/\\]generated[/\\]model[/\\]" checks=".*"/>
1112
<suppress files="[/\\]orchestration[/\\]model[/\\]" checks=".*"/>
1213
<!-- Suppress TODOs -->
1314
<suppress files="OpenAiChatMessage.java" checks="TodoComment" lines="257,7" />
15+
<suppress files="ChatCompletionResponseMessage.java" checks="TodoComment" lines="53,34" />
16+
<suppress files="CreateChatCompletionRequest.java" checks="TodoComment" lines="73,47" />
1417
</suppressions>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
/*
2+
* Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved.
3+
*/
4+
5+
/*
6+
* Azure OpenAI Service API
7+
* Azure OpenAI APIs for completions and search
8+
*
9+
* The version of the OpenAPI document: 2024-10-21
10+
*
11+
*
12+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
13+
* https://openapi-generator.tech
14+
* Do not edit the class manually.
15+
*/
16+
17+
package com.sap.ai.sdk.foundationmodels.openai.generated.model;
18+
19+
import com.fasterxml.jackson.annotation.JsonAnyGetter;
20+
import com.fasterxml.jackson.annotation.JsonAnySetter;
21+
import com.fasterxml.jackson.annotation.JsonIgnore;
22+
import com.fasterxml.jackson.annotation.JsonProperty;
23+
import java.util.LinkedHashMap;
24+
import java.util.Map;
25+
import java.util.NoSuchElementException;
26+
import java.util.Objects;
27+
import java.util.Set;
28+
import javax.annotation.Nonnull;
29+
import javax.annotation.Nullable;
30+
31+
/**
32+
* Deprecated and replaced by &#x60;tool_calls&#x60;. The name and arguments of a function that
33+
* should be called, as generated by the model.
34+
*/
35+
// CHECKSTYLE:OFF
36+
@com.google.common.annotations.Beta
37+
public class ChatCompletionFunctionCall
38+
// CHECKSTYLE:ON
39+
{
40+
@JsonProperty("name")
41+
private String name;
42+
43+
@JsonProperty("arguments")
44+
private String arguments;
45+
46+
@JsonAnySetter @JsonAnyGetter
47+
private final Map<String, Object> cloudSdkCustomFields = new LinkedHashMap<>();
48+
49+
/**
50+
* Set the name of this {@link ChatCompletionFunctionCall} instance and return the same instance.
51+
*
52+
* @param name The name of the function to call.
53+
* @return The same instance of this {@link ChatCompletionFunctionCall} class
54+
*/
55+
@Nonnull
56+
public ChatCompletionFunctionCall name(@Nonnull final String name) {
57+
this.name = name;
58+
return this;
59+
}
60+
61+
/**
62+
* The name of the function to call.
63+
*
64+
* @return name The name of this {@link ChatCompletionFunctionCall} instance.
65+
*/
66+
@Nonnull
67+
public String getName() {
68+
return name;
69+
}
70+
71+
/**
72+
* Set the name of this {@link ChatCompletionFunctionCall} instance.
73+
*
74+
* @param name The name of the function to call.
75+
*/
76+
public void setName(@Nonnull final String name) {
77+
this.name = name;
78+
}
79+
80+
/**
81+
* Set the arguments of this {@link ChatCompletionFunctionCall} instance and return the same
82+
* instance.
83+
*
84+
* @param arguments The arguments to call the function with, as generated by the model in JSON
85+
* format. Note that the model does not always generate valid JSON, and may hallucinate
86+
* parameters not defined by your function schema. Validate the arguments in your code before
87+
* calling your function.
88+
* @return The same instance of this {@link ChatCompletionFunctionCall} class
89+
*/
90+
@Nonnull
91+
public ChatCompletionFunctionCall arguments(@Nonnull final String arguments) {
92+
this.arguments = arguments;
93+
return this;
94+
}
95+
96+
/**
97+
* The arguments to call the function with, as generated by the model in JSON format. Note that
98+
* the model does not always generate valid JSON, and may hallucinate parameters not defined by
99+
* your function schema. Validate the arguments in your code before calling your function.
100+
*
101+
* @return arguments The arguments of this {@link ChatCompletionFunctionCall} instance.
102+
*/
103+
@Nonnull
104+
public String getArguments() {
105+
return arguments;
106+
}
107+
108+
/**
109+
* Set the arguments of this {@link ChatCompletionFunctionCall} instance.
110+
*
111+
* @param arguments The arguments to call the function with, as generated by the model in JSON
112+
* format. Note that the model does not always generate valid JSON, and may hallucinate
113+
* parameters not defined by your function schema. Validate the arguments in your code before
114+
* calling your function.
115+
*/
116+
public void setArguments(@Nonnull final String arguments) {
117+
this.arguments = arguments;
118+
}
119+
120+
/**
121+
* Get the names of the unrecognizable properties of the {@link ChatCompletionFunctionCall}.
122+
*
123+
* @return The set of properties names
124+
*/
125+
@JsonIgnore
126+
@Nonnull
127+
public Set<String> getCustomFieldNames() {
128+
return cloudSdkCustomFields.keySet();
129+
}
130+
131+
/**
132+
* Get the value of an unrecognizable property of this {@link ChatCompletionFunctionCall}
133+
* instance.
134+
*
135+
* @param name The name of the property
136+
* @return The value of the property
137+
* @throws NoSuchElementException If no property with the given name could be found.
138+
*/
139+
@Nullable
140+
public Object getCustomField(@Nonnull final String name) throws NoSuchElementException {
141+
if (!cloudSdkCustomFields.containsKey(name)) {
142+
throw new NoSuchElementException(
143+
"ChatCompletionFunctionCall has no field with name '" + name + "'.");
144+
}
145+
return cloudSdkCustomFields.get(name);
146+
}
147+
148+
/**
149+
* Set an unrecognizable property of this {@link ChatCompletionFunctionCall} instance. If the map
150+
* previously contained a mapping for the key, the old value is replaced by the specified value.
151+
*
152+
* @param customFieldName The name of the property
153+
* @param customFieldValue The value of the property
154+
*/
155+
@JsonIgnore
156+
public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) {
157+
cloudSdkCustomFields.put(customFieldName, customFieldValue);
158+
}
159+
160+
@Override
161+
public boolean equals(@Nullable final Object o) {
162+
if (this == o) {
163+
return true;
164+
}
165+
if (o == null || getClass() != o.getClass()) {
166+
return false;
167+
}
168+
final ChatCompletionFunctionCall chatCompletionFunctionCall = (ChatCompletionFunctionCall) o;
169+
return Objects.equals(
170+
this.cloudSdkCustomFields, chatCompletionFunctionCall.cloudSdkCustomFields)
171+
&& Objects.equals(this.name, chatCompletionFunctionCall.name)
172+
&& Objects.equals(this.arguments, chatCompletionFunctionCall.arguments);
173+
}
174+
175+
@Override
176+
public int hashCode() {
177+
return Objects.hash(name, arguments, cloudSdkCustomFields);
178+
}
179+
180+
@Override
181+
@Nonnull
182+
public String toString() {
183+
final StringBuilder sb = new StringBuilder();
184+
sb.append("class ChatCompletionFunctionCall {\n");
185+
sb.append(" name: ").append(toIndentedString(name)).append("\n");
186+
sb.append(" arguments: ").append(toIndentedString(arguments)).append("\n");
187+
cloudSdkCustomFields.forEach(
188+
(k, v) ->
189+
sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n"));
190+
sb.append("}");
191+
return sb.toString();
192+
}
193+
194+
/**
195+
* Convert the given object to string with each line indented by 4 spaces (except the first line).
196+
*/
197+
private String toIndentedString(final Object o) {
198+
if (o == null) {
199+
return "null";
200+
}
201+
return o.toString().replace("\n", "\n ");
202+
}
203+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
/*
2+
* Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved.
3+
*/
4+
5+
/*
6+
* Azure OpenAI Service API
7+
* Azure OpenAI APIs for completions and search
8+
*
9+
* The version of the OpenAPI document: 2024-10-21
10+
*
11+
*
12+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
13+
* https://openapi-generator.tech
14+
* Do not edit the class manually.
15+
*/
16+
17+
package com.sap.ai.sdk.foundationmodels.openai.generated.model;
18+
19+
import com.fasterxml.jackson.annotation.JsonAnyGetter;
20+
import com.fasterxml.jackson.annotation.JsonAnySetter;
21+
import com.fasterxml.jackson.annotation.JsonIgnore;
22+
import com.fasterxml.jackson.annotation.JsonProperty;
23+
import java.util.LinkedHashMap;
24+
import java.util.Map;
25+
import java.util.NoSuchElementException;
26+
import java.util.Objects;
27+
import java.util.Set;
28+
import javax.annotation.Nonnull;
29+
import javax.annotation.Nullable;
30+
31+
/**
32+
* Specifying a particular function via &#x60;{\&quot;name\&quot;: \&quot;my_function\&quot;}&#x60;
33+
* forces the model to call that function.
34+
*/
35+
// CHECKSTYLE:OFF
36+
@com.google.common.annotations.Beta
37+
public class ChatCompletionFunctionCallOption
38+
// CHECKSTYLE:ON
39+
{
40+
@JsonProperty("name")
41+
private String name;
42+
43+
@JsonAnySetter @JsonAnyGetter
44+
private final Map<String, Object> cloudSdkCustomFields = new LinkedHashMap<>();
45+
46+
/**
47+
* Set the name of this {@link ChatCompletionFunctionCallOption} instance and return the same
48+
* instance.
49+
*
50+
* @param name The name of the function to call.
51+
* @return The same instance of this {@link ChatCompletionFunctionCallOption} class
52+
*/
53+
@Nonnull
54+
public ChatCompletionFunctionCallOption name(@Nonnull final String name) {
55+
this.name = name;
56+
return this;
57+
}
58+
59+
/**
60+
* The name of the function to call.
61+
*
62+
* @return name The name of this {@link ChatCompletionFunctionCallOption} instance.
63+
*/
64+
@Nonnull
65+
public String getName() {
66+
return name;
67+
}
68+
69+
/**
70+
* Set the name of this {@link ChatCompletionFunctionCallOption} instance.
71+
*
72+
* @param name The name of the function to call.
73+
*/
74+
public void setName(@Nonnull final String name) {
75+
this.name = name;
76+
}
77+
78+
/**
79+
* Get the names of the unrecognizable properties of the {@link ChatCompletionFunctionCallOption}.
80+
*
81+
* @return The set of properties names
82+
*/
83+
@JsonIgnore
84+
@Nonnull
85+
public Set<String> getCustomFieldNames() {
86+
return cloudSdkCustomFields.keySet();
87+
}
88+
89+
/**
90+
* Get the value of an unrecognizable property of this {@link ChatCompletionFunctionCallOption}
91+
* instance.
92+
*
93+
* @param name The name of the property
94+
* @return The value of the property
95+
* @throws NoSuchElementException If no property with the given name could be found.
96+
*/
97+
@Nullable
98+
public Object getCustomField(@Nonnull final String name) throws NoSuchElementException {
99+
if (!cloudSdkCustomFields.containsKey(name)) {
100+
throw new NoSuchElementException(
101+
"ChatCompletionFunctionCallOption has no field with name '" + name + "'.");
102+
}
103+
return cloudSdkCustomFields.get(name);
104+
}
105+
106+
/**
107+
* Set an unrecognizable property of this {@link ChatCompletionFunctionCallOption} instance. If
108+
* the map previously contained a mapping for the key, the old value is replaced by the specified
109+
* value.
110+
*
111+
* @param customFieldName The name of the property
112+
* @param customFieldValue The value of the property
113+
*/
114+
@JsonIgnore
115+
public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) {
116+
cloudSdkCustomFields.put(customFieldName, customFieldValue);
117+
}
118+
119+
@Override
120+
public boolean equals(@Nullable final Object o) {
121+
if (this == o) {
122+
return true;
123+
}
124+
if (o == null || getClass() != o.getClass()) {
125+
return false;
126+
}
127+
final ChatCompletionFunctionCallOption chatCompletionFunctionCallOption =
128+
(ChatCompletionFunctionCallOption) o;
129+
return Objects.equals(
130+
this.cloudSdkCustomFields, chatCompletionFunctionCallOption.cloudSdkCustomFields)
131+
&& Objects.equals(this.name, chatCompletionFunctionCallOption.name);
132+
}
133+
134+
@Override
135+
public int hashCode() {
136+
return Objects.hash(name, cloudSdkCustomFields);
137+
}
138+
139+
@Override
140+
@Nonnull
141+
public String toString() {
142+
final StringBuilder sb = new StringBuilder();
143+
sb.append("class ChatCompletionFunctionCallOption {\n");
144+
sb.append(" name: ").append(toIndentedString(name)).append("\n");
145+
cloudSdkCustomFields.forEach(
146+
(k, v) ->
147+
sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n"));
148+
sb.append("}");
149+
return sb.toString();
150+
}
151+
152+
/**
153+
* Convert the given object to string with each line indented by 4 spaces (except the first line).
154+
*/
155+
private String toIndentedString(final Object o) {
156+
if (o == null) {
157+
return "null";
158+
}
159+
return o.toString().replace("\n", "\n ");
160+
}
161+
}

0 commit comments

Comments
 (0)