66import static com .sap .ai .sdk .orchestration .OrchestrationAiModel .Parameter .TEMPERATURE ;
77import static com .sap .ai .sdk .orchestration .OrchestrationAiModel .Parameter .TOP_P ;
88
9+ import com .google .common .annotations .Beta ;
910import com .sap .ai .sdk .orchestration .OrchestrationModuleConfig ;
1011import com .sap .ai .sdk .orchestration .model .LLMModuleConfig ;
11- import java .util .ArrayList ;
12- import java .util .LinkedHashMap ;
1312import java .util .List ;
13+ import java .util .Map ;
1414import java .util .Objects ;
1515import javax .annotation .Nonnull ;
1616import javax .annotation .Nullable ;
2121import lombok .val ;
2222import org .springframework .ai .chat .prompt .ChatOptions ;
2323
24- /** Configuration to be used for orchestration requests. */
24+ /**
25+ * Configuration to be used for orchestration requests.
26+ *
27+ * @since 1.2.0
28+ */
29+ @ Beta
2530@ Data
2631@ Getter (AccessLevel .NONE )
2732@ Setter (AccessLevel .NONE )
@@ -73,10 +78,6 @@ public Double getFrequencyPenalty() {
7378 return getLlmConfigParam (FREQUENCY_PENALTY .getName ());
7479 }
7580
76- private void setFrequencyPenalty (@ Nonnull final Double frequencyPenalty ) {
77- setLlmConfigParam (FREQUENCY_PENALTY .getName (), frequencyPenalty );
78- }
79-
8081 /**
8182 * Returns the maximum number of tokens to use for the chat.
8283 *
@@ -88,10 +89,6 @@ public Integer getMaxTokens() {
8889 return getLlmConfigParam (MAX_TOKENS .getName ());
8990 }
9091
91- private void setMaxTokens (@ Nonnull final Integer maxTokens ) {
92- setLlmConfigParam (MAX_TOKENS .getName (), maxTokens );
93- }
94-
9592 /**
9693 * Returns the presence penalty to use for the chat.
9794 *
@@ -103,10 +100,6 @@ public Double getPresencePenalty() {
103100 return getLlmConfigParam (PRESENCE_PENALTY .getName ());
104101 }
105102
106- private void setPresencePenalty (@ Nonnull final Double presencePenalty ) {
107- setLlmConfigParam (PRESENCE_PENALTY .getName (), presencePenalty );
108- }
109-
110103 /**
111104 * Returns the stop sequences to use for the chat.
112105 *
@@ -118,10 +111,6 @@ public List<String> getStopSequences() {
118111 return getLlmConfigParam ("stop_sequences" );
119112 }
120113
121- private void setStopSequences (@ Nonnull final List <String > stopSequences ) {
122- setLlmConfigParam ("stop_sequences" , stopSequences );
123- }
124-
125114 /**
126115 * Returns the temperature to use for the chat.
127116 *
@@ -133,10 +122,6 @@ public Double getTemperature() {
133122 return getLlmConfigParam (TEMPERATURE .getName ());
134123 }
135124
136- private void setTemperature (@ Nonnull final Double temperature ) {
137- setLlmConfigParam (TEMPERATURE .getName (), temperature );
138- }
139-
140125 /**
141126 * Returns the top K to use for the chat.
142127 *
@@ -148,10 +133,6 @@ public Integer getTopK() {
148133 return getLlmConfigParam ("top_k" );
149134 }
150135
151- private void setTopK (@ Nonnull final Integer topK ) {
152- setLlmConfigParam ("top_k" , topK );
153- }
154-
155136 /**
156137 * Returns the top P to use for the chat.
157138 *
@@ -163,10 +144,6 @@ public Double getTopP() {
163144 return getLlmConfigParam (TOP_P .getName ());
164145 }
165146
166- private void setTopP (@ Nonnull final Double topP ) {
167- setLlmConfigParam (TOP_P .getName (), topP );
168- }
169-
170147 /**
171148 * Returns a copy of this {@link OrchestrationChatOptions}.
172149 *
@@ -180,41 +157,41 @@ public <T extends ChatOptions> T copy() {
180157 copy .setModel (this .getModel ());
181158 copy .setModelVersion (this .getModelVersion ());
182159 if (getFrequencyPenalty () != null ) {
183- copy .setFrequencyPenalty ( this . getFrequencyPenalty ());
160+ copy .setLlmConfigParam ( FREQUENCY_PENALTY . getName (), getFrequencyPenalty ());
184161 }
185162 if (getMaxTokens () != null ) {
186- copy .setMaxTokens ( this . getMaxTokens ());
163+ copy .setLlmConfigParam ( MAX_TOKENS . getName (), getMaxTokens ());
187164 }
188165 if (getPresencePenalty () != null ) {
189- copy .setPresencePenalty ( this . getPresencePenalty ());
166+ copy .setLlmConfigParam ( PRESENCE_PENALTY . getName (), getPresencePenalty ());
190167 }
191168 if (getStopSequences () != null ) {
192- copy .setStopSequences ( new ArrayList <>( this . getStopSequences () ));
169+ copy .setLlmConfigParam ( "stop_sequences" , getStopSequences ());
193170 }
194171 if (getTemperature () != null ) {
195- copy .setTemperature ( this . getTemperature ());
172+ copy .setLlmConfigParam ( TEMPERATURE . getName (), getTemperature ());
196173 }
197174 if (getTopK () != null ) {
198- copy .setTopK ( this . getTopK ());
175+ copy .setLlmConfigParam ( "top_k" , getTopK ());
199176 }
200177 if (getTopP () != null ) {
201- copy .setTopP ( this . getTopP ());
178+ copy .setLlmConfigParam ( TOP_P . getName (), getTopP ());
202179 }
203180 return (T ) copy ;
204181 }
205182
206183 @ SuppressWarnings ("unchecked" )
207184 @ Nullable
208185 private <T > T getLlmConfigParam (@ Nonnull final String param ) {
209- if (getLlmConfigNonNull ().getModelParams () instanceof LinkedHashMap ) {
210- return ((LinkedHashMap <String , T >) getLlmConfigNonNull ().getModelParams ()).get (param );
186+ if (getLlmConfigNonNull ().getModelParams () instanceof Map ) {
187+ return ((Map <String , T >) getLlmConfigNonNull ().getModelParams ()).get (param );
211188 }
212189 return null ;
213190 }
214191
215192 @ SuppressWarnings ("unchecked" )
216- private < T > void setLlmConfigParam (@ Nonnull final String param , @ Nonnull final T value ) {
217- ((LinkedHashMap <String , T >) getLlmConfigNonNull ().getModelParams ()).put (param , value );
193+ private void setLlmConfigParam (@ Nonnull final String param , @ Nonnull final Object value ) {
194+ ((Map <String , Object >) getLlmConfigNonNull ().getModelParams ()).put (param , value );
218195 }
219196
220197 @ Nonnull
0 commit comments