|
2 | 2 |
|
3 | 3 | import static io.quarkiverse.langchain4j.runtime.OptionalUtil.firstOrDefault; |
4 | 4 |
|
| 5 | +import java.net.InetSocketAddress; |
| 6 | +import java.net.Proxy; |
| 7 | +import java.net.Proxy.Type; |
5 | 8 | import java.nio.file.Path; |
6 | 9 | import java.nio.file.Paths; |
7 | 10 | import java.time.Duration; |
@@ -84,6 +87,11 @@ public Function<SyntheticCreationalContext<ChatModel>, ChatModel> chatModel(Stri |
84 | 87 | .frequencyPenalty(chatModelConfig.frequencyPenalty()) |
85 | 88 | .responseFormat(chatModelConfig.responseFormat().orElse(null)); |
86 | 89 |
|
| 90 | + azureAiConfig.proxyHost().ifPresent(host -> { |
| 91 | + builder.proxy(new Proxy( |
| 92 | + Type.valueOf(azureAiConfig.proxyType()), |
| 93 | + new InetSocketAddress(host, azureAiConfig.proxyPort()))); |
| 94 | + }); |
87 | 95 | if (chatModelConfig.maxTokens().isPresent()) { |
88 | 96 | builder.maxTokens(chatModelConfig.maxTokens().get()); |
89 | 97 | } |
@@ -133,6 +141,12 @@ public Function<SyntheticCreationalContext<StreamingChatModel>, StreamingChatMod |
133 | 141 | .frequencyPenalty(chatModelConfig.frequencyPenalty()) |
134 | 142 | .responseFormat(chatModelConfig.responseFormat().orElse(null)); |
135 | 143 |
|
| 144 | + azureAiConfig.proxyHost().ifPresent(host -> { |
| 145 | + builder.proxy(new Proxy( |
| 146 | + Type.valueOf(azureAiConfig.proxyType()), |
| 147 | + new InetSocketAddress(host, azureAiConfig.proxyPort()))); |
| 148 | + }); |
| 149 | + |
136 | 150 | if (chatModelConfig.maxTokens().isPresent()) { |
137 | 151 | builder.maxTokens(chatModelConfig.maxTokens().get()); |
138 | 152 | } |
@@ -176,6 +190,12 @@ public Function<SyntheticCreationalContext<EmbeddingModel>, EmbeddingModel> embe |
176 | 190 | .logRequests(firstOrDefault(false, embeddingModelConfig.logRequests(), azureAiConfig.logRequests())) |
177 | 191 | .logResponses(firstOrDefault(false, embeddingModelConfig.logResponses(), azureAiConfig.logResponses())); |
178 | 192 |
|
| 193 | + azureAiConfig.proxyHost().ifPresent(host -> { |
| 194 | + builder.proxy(new Proxy( |
| 195 | + Type.valueOf(azureAiConfig.proxyType()), |
| 196 | + new InetSocketAddress(host, azureAiConfig.proxyPort()))); |
| 197 | + }); |
| 198 | + |
179 | 199 | return new Function<>() { |
180 | 200 | @Override |
181 | 201 | public EmbeddingModel apply(SyntheticCreationalContext<EmbeddingModel> context) { |
|
0 commit comments