|
30 | 30 | import io.quarkiverse.langchain4j.azure.openai.AzureOpenAiImageModel; |
31 | 31 | import io.quarkiverse.langchain4j.azure.openai.AzureOpenAiStreamingChatModel; |
32 | 32 | import io.quarkiverse.langchain4j.azure.openai.runtime.config.ChatModelConfig; |
33 | | -import io.quarkiverse.langchain4j.azure.openai.runtime.config.EmbeddingModelConfig; |
34 | 33 | import io.quarkiverse.langchain4j.azure.openai.runtime.config.LangChain4jAzureOpenAiConfig; |
35 | 34 | import io.quarkiverse.langchain4j.azure.openai.runtime.config.LangChain4jAzureOpenAiConfig.AzureAiConfig.EndpointType; |
36 | 35 | import io.quarkiverse.langchain4j.openai.common.QuarkusOpenAiClient; |
@@ -58,17 +57,16 @@ public Function<SyntheticCreationalContext<ChatLanguageModel>, ChatLanguageModel |
58 | 57 | LangChain4jAzureOpenAiConfig.AzureAiConfig azureAiConfig = correspondingAzureOpenAiConfig(runtimeConfig, configName); |
59 | 58 |
|
60 | 59 | if (azureAiConfig.enableIntegration()) { |
61 | | - ChatModelConfig chatModelConfig = azureAiConfig.chatModel(); |
62 | | - String apiKey = azureAiConfig.apiKey().orElse(null); |
63 | | - String adToken = azureAiConfig.adToken().orElse(null); |
64 | | - |
| 60 | + var chatModelConfig = azureAiConfig.chatModel(); |
| 61 | + var apiKey = firstOrDefault(null, chatModelConfig.apiKey(), azureAiConfig.apiKey()); |
| 62 | + var adToken = firstOrDefault(null, chatModelConfig.adToken(), azureAiConfig.adToken()); |
65 | 63 | var builder = AzureOpenAiChatModel.builder() |
66 | 64 | .endpoint(getEndpoint(azureAiConfig, configName, EndpointType.CHAT)) |
67 | 65 | .configName(NamedConfigUtil.isDefault(configName) ? null : configName) |
68 | 66 | .apiKey(apiKey) |
69 | 67 | .adToken(adToken) |
70 | 68 | // .tokenizer(new OpenAiTokenizer("<modelName>")) TODO: Set the tokenizer, it is always null!! |
71 | | - .apiVersion(azureAiConfig.apiVersion()) |
| 69 | + .apiVersion(chatModelConfig.apiVersion().orElse(azureAiConfig.apiVersion())) |
72 | 70 | .timeout(azureAiConfig.timeout().orElse(Duration.ofSeconds(10))) |
73 | 71 | .maxRetries(azureAiConfig.maxRetries()) |
74 | 72 | .logRequests(firstOrDefault(false, chatModelConfig.logRequests(), azureAiConfig.logRequests())) |
@@ -158,15 +156,15 @@ public Function<SyntheticCreationalContext<EmbeddingModel>, EmbeddingModel> embe |
158 | 156 | LangChain4jAzureOpenAiConfig.AzureAiConfig azureAiConfig = correspondingAzureOpenAiConfig(runtimeConfig, configName); |
159 | 157 |
|
160 | 158 | if (azureAiConfig.enableIntegration()) { |
161 | | - EmbeddingModelConfig embeddingModelConfig = azureAiConfig.embeddingModel(); |
162 | | - String apiKey = azureAiConfig.apiKey().orElse(null); |
163 | | - String adToken = azureAiConfig.adToken().orElse(null); |
| 159 | + var embeddingModelConfig = azureAiConfig.embeddingModel(); |
| 160 | + var apiKey = firstOrDefault(null, embeddingModelConfig.apiKey(), azureAiConfig.apiKey()); |
| 161 | + var adToken = firstOrDefault(null, embeddingModelConfig.adToken(), azureAiConfig.adToken()); |
164 | 162 | var builder = AzureOpenAiEmbeddingModel.builder() |
165 | 163 | .endpoint(getEndpoint(azureAiConfig, configName, EndpointType.EMBEDDING)) |
166 | 164 | .apiKey(apiKey) |
167 | 165 | .adToken(adToken) |
168 | 166 | .configName(NamedConfigUtil.isDefault(configName) ? null : configName) |
169 | | - .apiVersion(azureAiConfig.apiVersion()) |
| 167 | + .apiVersion(embeddingModelConfig.apiVersion().orElse(azureAiConfig.apiVersion())) |
170 | 168 | .timeout(azureAiConfig.timeout().orElse(Duration.ofSeconds(10))) |
171 | 169 | .maxRetries(azureAiConfig.maxRetries()) |
172 | 170 | .logRequests(firstOrDefault(false, embeddingModelConfig.logRequests(), azureAiConfig.logRequests())) |
@@ -195,15 +193,14 @@ public Function<SyntheticCreationalContext<ImageModel>, ImageModel> imageModel(L |
195 | 193 | LangChain4jAzureOpenAiConfig.AzureAiConfig azureAiConfig = correspondingAzureOpenAiConfig(runtimeConfig, configName); |
196 | 194 |
|
197 | 195 | if (azureAiConfig.enableIntegration()) { |
198 | | - var apiKey = azureAiConfig.apiKey().orElse(null); |
199 | | - String adToken = azureAiConfig.adToken().orElse(null); |
200 | | - |
201 | 196 | var imageModelConfig = azureAiConfig.imageModel(); |
| 197 | + var apiKey = firstOrDefault(null, imageModelConfig.apiKey(), azureAiConfig.apiKey()); |
| 198 | + var adToken = firstOrDefault(null, imageModelConfig.adToken(), azureAiConfig.adToken()); |
202 | 199 | var builder = AzureOpenAiImageModel.builder() |
203 | 200 | .endpoint(getEndpoint(azureAiConfig, configName, EndpointType.IMAGE)) |
204 | 201 | .apiKey(apiKey) |
205 | 202 | .adToken(adToken) |
206 | | - .apiVersion(azureAiConfig.apiVersion()) |
| 203 | + .apiVersion(imageModelConfig.apiVersion().orElse(azureAiConfig.apiVersion())) |
207 | 204 | .timeout(azureAiConfig.timeout().orElse(Duration.ofSeconds(10))) |
208 | 205 | .maxRetries(azureAiConfig.maxRetries()) |
209 | 206 | .logRequests(firstOrDefault(false, imageModelConfig.logRequests(), azureAiConfig.logRequests())) |
|
0 commit comments