Skip to content

Commit

Permalink
fix #2038 Add custom-headers to the Azure Open AI Spring Boot Starter (
Browse files Browse the repository at this point in the history
…#50)

Fix issue langchain4j/langchain4j#2038

Is there any markdown documentation file to complete?
Do I need to create an integration test? If so, how?
  • Loading branch information
arey authored Nov 7, 2024
1 parent 3fbf707 commit f06f833
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ AzureOpenAiChatModel openAiChatModel(Properties properties) {
.timeout(Duration.ofSeconds(chatModelProperties.getTimeout() == null ? 0 : chatModelProperties.getTimeout()))
.maxRetries(chatModelProperties.getMaxRetries())
.proxyOptions(ProxyOptions.fromConfiguration(Configuration.getGlobalConfiguration()))
.customHeaders(chatModelProperties.getCustomHeaders())
.logRequestsAndResponses(chatModelProperties.getLogRequestsAndResponses() != null && chatModelProperties.getLogRequestsAndResponses());
if (chatModelProperties.getNonAzureApiKey() != null) {
builder.nonAzureApiKey(chatModelProperties.getNonAzureApiKey());
Expand Down Expand Up @@ -81,6 +82,7 @@ AzureOpenAiStreamingChatModel openAiStreamingChatModel(Properties properties) {
.frequencyPenalty(chatModelProperties.getFrequencyPenalty())
.timeout(Duration.ofSeconds(chatModelProperties.getTimeout() == null ? 0 : chatModelProperties.getTimeout()))
.proxyOptions(ProxyOptions.fromConfiguration(Configuration.getGlobalConfiguration()))
.customHeaders(chatModelProperties.getCustomHeaders())
.logRequestsAndResponses(chatModelProperties.getLogRequestsAndResponses() != null && chatModelProperties.getLogRequestsAndResponses());
if (chatModelProperties.getNonAzureApiKey() != null) {
builder.nonAzureApiKey(chatModelProperties.getNonAzureApiKey());
Expand Down Expand Up @@ -110,6 +112,7 @@ AzureOpenAiEmbeddingModel openAiEmbeddingModel(Properties properties, Tokenizer
.tokenizer(tokenizer)
.timeout(Duration.ofSeconds(embeddingModelProperties.getTimeout() == null ? 0 : embeddingModelProperties.getTimeout()))
.proxyOptions(ProxyOptions.fromConfiguration(Configuration.getGlobalConfiguration()))
.customHeaders(embeddingModelProperties.getCustomHeaders())
.logRequestsAndResponses(embeddingModelProperties.getLogRequestsAndResponses() != null && embeddingModelProperties.getLogRequestsAndResponses());

if (embeddingModelProperties.getNonAzureApiKey() != null) {
Expand Down Expand Up @@ -144,6 +147,7 @@ AzureOpenAiImageModel openAiImageModel(Properties properties) {
.timeout(imageModelProperties.getTimeout() == null ? null : Duration.ofSeconds(imageModelProperties.getTimeout()))
.maxRetries(imageModelProperties.getMaxRetries())
.proxyOptions(ProxyOptions.fromConfiguration(Configuration.getGlobalConfiguration()))
.customHeaders(imageModelProperties.getCustomHeaders())
.logRequestsAndResponses(imageModelProperties.getLogRequestsAndResponses() != null && imageModelProperties.getLogRequestsAndResponses());
if (imageModelProperties.getNonAzureApiKey() != null) {
builder.nonAzureApiKey(imageModelProperties.getNonAzureApiKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.Setter;

import java.util.List;
import java.util.Map;

@Getter
@Setter
Expand All @@ -25,4 +26,5 @@ class ChatModelProperties {
Integer timeout;
Integer maxRetries;
Boolean logRequestsAndResponses;
Map<String, String> customHeaders;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import lombok.Getter;
import lombok.Setter;

import java.util.Map;

@Getter
@Setter
class EmbeddingModelProperties {
Expand All @@ -15,4 +17,5 @@ class EmbeddingModelProperties {
Integer timeout;
Integer maxRetries;
Boolean logRequestsAndResponses;
Map<String, String> customHeaders;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import lombok.Getter;
import lombok.Setter;

import java.util.Map;

@Getter
@Setter
class ImageModelProperties {
Expand All @@ -19,4 +21,5 @@ class ImageModelProperties {
Integer timeout;
Integer maxRetries;
Boolean logRequestsAndResponses;
Map<String, String> customHeaders;
}

0 comments on commit f06f833

Please sign in to comment.