|
1 | 1 | package com.sap.ai.sdk.orchestration.spring; |
2 | 2 |
|
3 | | -import static com.sap.ai.sdk.orchestration.ConfigToRequestTransformer.toModuleConfigs; |
4 | 3 | import static com.sap.ai.sdk.orchestration.OrchestrationAiModel.Parameter.FREQUENCY_PENALTY; |
5 | 4 | import static com.sap.ai.sdk.orchestration.OrchestrationAiModel.Parameter.MAX_TOKENS; |
6 | 5 | import static com.sap.ai.sdk.orchestration.OrchestrationAiModel.Parameter.PRESENCE_PENALTY; |
7 | 6 | import static com.sap.ai.sdk.orchestration.OrchestrationAiModel.Parameter.TEMPERATURE; |
8 | 7 | import static com.sap.ai.sdk.orchestration.OrchestrationAiModel.Parameter.TOP_P; |
9 | 8 | import static com.sap.ai.sdk.orchestration.OrchestrationJacksonConfiguration.getOrchestrationObjectMapper; |
10 | 9 |
|
11 | | -import com.fasterxml.jackson.core.JsonProcessingException; |
12 | 10 | import com.fasterxml.jackson.databind.ObjectMapper; |
13 | 11 | import com.google.common.annotations.Beta; |
14 | | -import com.sap.ai.sdk.orchestration.OrchestrationClientException; |
15 | 12 | import com.sap.ai.sdk.orchestration.OrchestrationModuleConfig; |
16 | 13 | import com.sap.ai.sdk.orchestration.model.LLMModuleConfig; |
17 | | -import com.sap.ai.sdk.orchestration.model.ModuleConfigs; |
18 | 14 | import java.util.List; |
19 | 15 | import java.util.Map; |
20 | 16 | import java.util.Objects; |
@@ -153,22 +149,14 @@ public Double getTopP() { |
153 | 149 | @Nonnull |
154 | 150 | @Override |
155 | 151 | public <T extends ChatOptions> T copy() { |
156 | | - try { |
157 | | - val json = JACKSON.writeValueAsString(toModuleConfigs(config)); |
158 | | - val copy = JACKSON.readValue(json, ModuleConfigs.class); |
159 | | - val copyConfig = |
160 | | - new OrchestrationModuleConfig() |
161 | | - .withTemplateConfig(copy.getTemplatingModuleConfig()) |
162 | | - .withFilteringConfig(copy.getFilteringModuleConfig()) |
163 | | - .withLlmConfig(copy.getLlmModuleConfig()) |
164 | | - .withMaskingConfig(copy.getMaskingModuleConfig()) |
165 | | - .withGroundingConfig(copy.getGroundingModuleConfig()); |
166 | | - return (T) new OrchestrationChatOptions(copyConfig); |
167 | | - |
168 | | - } catch (JsonProcessingException e) { |
169 | | - throw new OrchestrationClientException( |
170 | | - "Orchestration module configuration not readable: " + config, e); |
171 | | - } |
| 152 | + val copyConfig = |
| 153 | + new OrchestrationModuleConfig() |
| 154 | + .withTemplateConfig(config.getTemplateConfig()) |
| 155 | + .withFilteringConfig(config.getFilteringConfig()) |
| 156 | + .withLlmConfig(config.getLlmConfig()) |
| 157 | + .withMaskingConfig(config.getMaskingConfig()) |
| 158 | + .withGroundingConfig(config.getGroundingConfig()); |
| 159 | + return (T) new OrchestrationChatOptions(copyConfig); |
172 | 160 | } |
173 | 161 |
|
174 | 162 | @SuppressWarnings("unchecked") // getModelParams() returns Object, it should return Map |
|
0 commit comments