From 1b93003249f062d5250c540a533d1f1d0d6b49c1 Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Tue, 29 Oct 2024 10:23:18 +0100 Subject: [PATCH 1/2] langchain4j-spring-boot-starter get rid of lombok --- langchain4j-spring-boot-starter/pom.xml | 7 ------- .../java/dev/langchain4j/rag/spring/RagAutoConfig.java | 6 +++--- .../java/dev/langchain4j/rag/spring/RagProperties.java | 10 ++-------- .../langchain4j/rag/spring/RetrievalProperties.java | 10 +--------- 4 files changed, 6 insertions(+), 27 deletions(-) diff --git a/langchain4j-spring-boot-starter/pom.xml b/langchain4j-spring-boot-starter/pom.xml index 31c67d08..3d7fe46a 100644 --- a/langchain4j-spring-boot-starter/pom.xml +++ b/langchain4j-spring-boot-starter/pom.xml @@ -33,13 +33,6 @@ true - - - org.projectlombok - lombok - provided - - org.springframework.boot diff --git a/langchain4j-spring-boot-starter/src/main/java/dev/langchain4j/rag/spring/RagAutoConfig.java b/langchain4j-spring-boot-starter/src/main/java/dev/langchain4j/rag/spring/RagAutoConfig.java index 67eb1e3b..2e313053 100644 --- a/langchain4j-spring-boot-starter/src/main/java/dev/langchain4j/rag/spring/RagAutoConfig.java +++ b/langchain4j-spring-boot-starter/src/main/java/dev/langchain4j/rag/spring/RagAutoConfig.java @@ -37,11 +37,11 @@ ContentRetriever contentRetriever(EmbeddingModel embeddingModel, .embeddingModel(embeddingModel); if (ragProperties != null) { - RetrievalProperties retrievalProperties = ragProperties.getRetrieval(); + RetrievalProperties retrievalProperties = ragProperties.retrieval(); if (retrievalProperties != null) { builder - .maxResults(retrievalProperties.maxResults) - .minScore(retrievalProperties.minScore); + .maxResults(retrievalProperties.maxResults()) + .minScore(retrievalProperties.minScore()); } } diff --git a/langchain4j-spring-boot-starter/src/main/java/dev/langchain4j/rag/spring/RagProperties.java b/langchain4j-spring-boot-starter/src/main/java/dev/langchain4j/rag/spring/RagProperties.java index dd47aaba..05e99a46 100644 --- a/langchain4j-spring-boot-starter/src/main/java/dev/langchain4j/rag/spring/RagProperties.java +++ b/langchain4j-spring-boot-starter/src/main/java/dev/langchain4j/rag/spring/RagProperties.java @@ -1,17 +1,11 @@ package dev.langchain4j.rag.spring; -import lombok.Getter; -import lombok.Setter; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.NestedConfigurationProperty; -@Getter -@Setter -@ConfigurationProperties(prefix = RagProperties.PREFIX) -public class RagProperties { +@ConfigurationProperties(prefix = RagProperties.PREFIX) +public record RagProperties(@NestedConfigurationProperty RetrievalProperties retrieval) { static final String PREFIX = "langchain4j.rag"; - @NestedConfigurationProperty - RetrievalProperties retrieval; } diff --git a/langchain4j-spring-boot-starter/src/main/java/dev/langchain4j/rag/spring/RetrievalProperties.java b/langchain4j-spring-boot-starter/src/main/java/dev/langchain4j/rag/spring/RetrievalProperties.java index e8995ced..7b351fc1 100644 --- a/langchain4j-spring-boot-starter/src/main/java/dev/langchain4j/rag/spring/RetrievalProperties.java +++ b/langchain4j-spring-boot-starter/src/main/java/dev/langchain4j/rag/spring/RetrievalProperties.java @@ -1,12 +1,4 @@ package dev.langchain4j.rag.spring; -import lombok.Getter; -import lombok.Setter; - -@Getter -@Setter -class RetrievalProperties { - - Integer maxResults; - Double minScore; +record RetrievalProperties(Integer maxResults, Double minScore) { } From 91b79122730fe846541362935f5346db38d5ecf8 Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Tue, 29 Oct 2024 10:46:53 +0100 Subject: [PATCH 2/2] langchain4j-open-ai-spring-boot-starter get rid of lombok --- .../pom.xml | 7 - .../langchain4j/openai/spring/AutoConfig.java | 226 +++++++++--------- .../openai/spring/ChatModelProperties.java | 55 ++--- .../spring/EmbeddingModelProperties.java | 33 ++- .../openai/spring/ImageModelProperties.java | 42 ++-- .../spring/LanguageModelProperties.java | 30 ++- .../spring/ModerationModelProperties.java | 27 +-- .../langchain4j/openai/spring/Properties.java | 25 +- .../openai/spring/ProxyProperties.java | 13 +- 9 files changed, 217 insertions(+), 241 deletions(-) diff --git a/langchain4j-open-ai-spring-boot-starter/pom.xml b/langchain4j-open-ai-spring-boot-starter/pom.xml index 86f740c6..a680136c 100644 --- a/langchain4j-open-ai-spring-boot-starter/pom.xml +++ b/langchain4j-open-ai-spring-boot-starter/pom.xml @@ -33,13 +33,6 @@ true - - - org.projectlombok - lombok - provided - - org.springframework.boot diff --git a/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/AutoConfig.java b/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/AutoConfig.java index d3527a17..d0db55ac 100644 --- a/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/AutoConfig.java +++ b/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/AutoConfig.java @@ -16,162 +16,162 @@ public class AutoConfig { @Bean @ConditionalOnProperty(PREFIX + ".chat-model.api-key") OpenAiChatModel openAiChatModel(Properties properties) { - ChatModelProperties chatModelProperties = properties.getChatModel(); + ChatModelProperties chatModelProperties = properties.chatModel(); return OpenAiChatModel.builder() - .baseUrl(chatModelProperties.getBaseUrl()) - .apiKey(chatModelProperties.getApiKey()) - .organizationId(chatModelProperties.getOrganizationId()) - .modelName(chatModelProperties.getModelName()) - .temperature(chatModelProperties.getTemperature()) - .topP(chatModelProperties.getTopP()) - .stop(chatModelProperties.getStop()) - .maxTokens(chatModelProperties.getMaxTokens()) - .maxCompletionTokens(chatModelProperties.getMaxCompletionTokens()) - .presencePenalty(chatModelProperties.getPresencePenalty()) - .frequencyPenalty(chatModelProperties.getFrequencyPenalty()) - .logitBias(chatModelProperties.getLogitBias()) - .responseFormat(chatModelProperties.getResponseFormat()) - .strictJsonSchema(chatModelProperties.getStrictJsonSchema()) - .seed(chatModelProperties.getSeed()) - .user(chatModelProperties.getUser()) - .strictTools(chatModelProperties.getStrictTools()) - .parallelToolCalls(chatModelProperties.getParallelToolCalls()) - .timeout(chatModelProperties.getTimeout()) - .maxRetries(chatModelProperties.getMaxRetries()) - .proxy(ProxyProperties.convert(chatModelProperties.getProxy())) - .logRequests(chatModelProperties.getLogRequests()) - .logResponses(chatModelProperties.getLogResponses()) - .customHeaders(chatModelProperties.getCustomHeaders()) + .baseUrl(chatModelProperties.baseUrl()) + .apiKey(chatModelProperties.apiKey()) + .organizationId(chatModelProperties.organizationId()) + .modelName(chatModelProperties.modelName()) + .temperature(chatModelProperties.temperature()) + .topP(chatModelProperties.topP()) + .stop(chatModelProperties.stop()) + .maxTokens(chatModelProperties.maxTokens()) + .maxCompletionTokens(chatModelProperties.maxCompletionTokens()) + .presencePenalty(chatModelProperties.presencePenalty()) + .frequencyPenalty(chatModelProperties.frequencyPenalty()) + .logitBias(chatModelProperties.logitBias()) + .responseFormat(chatModelProperties.responseFormat()) + .strictJsonSchema(chatModelProperties.strictJsonSchema()) + .seed(chatModelProperties.seed()) + .user(chatModelProperties.user()) + .strictTools(chatModelProperties.strictTools()) + .parallelToolCalls(chatModelProperties.parallelToolCalls()) + .timeout(chatModelProperties.timeout()) + .maxRetries(chatModelProperties.maxRetries()) + .proxy(ProxyProperties.convert(chatModelProperties.proxy())) + .logRequests(chatModelProperties.logRequests()) + .logResponses(chatModelProperties.logResponses()) + .customHeaders(chatModelProperties.customHeaders()) .build(); } @Bean @ConditionalOnProperty(PREFIX + ".streaming-chat-model.api-key") OpenAiStreamingChatModel openAiStreamingChatModel(Properties properties) { - ChatModelProperties chatModelProperties = properties.getStreamingChatModel(); + ChatModelProperties chatModelProperties = properties.streamingChatModel(); return OpenAiStreamingChatModel.builder() - .baseUrl(chatModelProperties.getBaseUrl()) - .apiKey(chatModelProperties.getApiKey()) - .organizationId(chatModelProperties.getOrganizationId()) - .modelName(chatModelProperties.getModelName()) - .temperature(chatModelProperties.getTemperature()) - .topP(chatModelProperties.getTopP()) - .stop(chatModelProperties.getStop()) - .maxTokens(chatModelProperties.getMaxTokens()) - .maxCompletionTokens(chatModelProperties.getMaxCompletionTokens()) - .presencePenalty(chatModelProperties.getPresencePenalty()) - .frequencyPenalty(chatModelProperties.getFrequencyPenalty()) - .logitBias(chatModelProperties.getLogitBias()) - .responseFormat(chatModelProperties.getResponseFormat()) - .seed(chatModelProperties.getSeed()) - .user(chatModelProperties.getUser()) - .strictTools(chatModelProperties.getStrictTools()) - .parallelToolCalls(chatModelProperties.getParallelToolCalls()) - .timeout(chatModelProperties.getTimeout()) - .proxy(ProxyProperties.convert(chatModelProperties.getProxy())) - .logRequests(chatModelProperties.getLogRequests()) - .logResponses(chatModelProperties.getLogResponses()) - .customHeaders(chatModelProperties.getCustomHeaders()) + .baseUrl(chatModelProperties.baseUrl()) + .apiKey(chatModelProperties.apiKey()) + .organizationId(chatModelProperties.organizationId()) + .modelName(chatModelProperties.modelName()) + .temperature(chatModelProperties.temperature()) + .topP(chatModelProperties.topP()) + .stop(chatModelProperties.stop()) + .maxTokens(chatModelProperties.maxTokens()) + .maxCompletionTokens(chatModelProperties.maxCompletionTokens()) + .presencePenalty(chatModelProperties.presencePenalty()) + .frequencyPenalty(chatModelProperties.frequencyPenalty()) + .logitBias(chatModelProperties.logitBias()) + .responseFormat(chatModelProperties.responseFormat()) + .seed(chatModelProperties.seed()) + .user(chatModelProperties.user()) + .strictTools(chatModelProperties.strictTools()) + .parallelToolCalls(chatModelProperties.parallelToolCalls()) + .timeout(chatModelProperties.timeout()) + .proxy(ProxyProperties.convert(chatModelProperties.proxy())) + .logRequests(chatModelProperties.logRequests()) + .logResponses(chatModelProperties.logResponses()) + .customHeaders(chatModelProperties.customHeaders()) .build(); } @Bean @ConditionalOnProperty(PREFIX + ".language-model.api-key") OpenAiLanguageModel openAiLanguageModel(Properties properties) { - LanguageModelProperties languageModelProperties = properties.getLanguageModel(); + LanguageModelProperties languageModelProperties = properties.languageModel(); return OpenAiLanguageModel.builder() - .baseUrl(languageModelProperties.getBaseUrl()) - .apiKey(languageModelProperties.getApiKey()) - .organizationId(languageModelProperties.getOrganizationId()) - .modelName(languageModelProperties.getModelName()) - .temperature(languageModelProperties.getTemperature()) - .timeout(languageModelProperties.getTimeout()) - .maxRetries(languageModelProperties.getMaxRetries()) - .proxy(ProxyProperties.convert(languageModelProperties.getProxy())) - .logRequests(languageModelProperties.getLogRequests()) - .logResponses(languageModelProperties.getLogResponses()) - .customHeaders(languageModelProperties.getCustomHeaders()) + .baseUrl(languageModelProperties.baseUrl()) + .apiKey(languageModelProperties.apiKey()) + .organizationId(languageModelProperties.organizationId()) + .modelName(languageModelProperties.modelName()) + .temperature(languageModelProperties.temperature()) + .timeout(languageModelProperties.timeout()) + .maxRetries(languageModelProperties.maxRetries()) + .proxy(ProxyProperties.convert(languageModelProperties.proxy())) + .logRequests(languageModelProperties.logRequests()) + .logResponses(languageModelProperties.logResponses()) + .customHeaders(languageModelProperties.customHeaders()) .build(); } @Bean @ConditionalOnProperty(PREFIX + ".streaming-language-model.api-key") OpenAiStreamingLanguageModel openAiStreamingLanguageModel(Properties properties) { - LanguageModelProperties languageModelProperties = properties.getStreamingLanguageModel(); + LanguageModelProperties languageModelProperties = properties.streamingLanguageModel(); return OpenAiStreamingLanguageModel.builder() - .baseUrl(languageModelProperties.getBaseUrl()) - .apiKey(languageModelProperties.getApiKey()) - .organizationId(languageModelProperties.getOrganizationId()) - .modelName(languageModelProperties.getModelName()) - .temperature(languageModelProperties.getTemperature()) - .timeout(languageModelProperties.getTimeout()) - .proxy(ProxyProperties.convert(languageModelProperties.getProxy())) - .logRequests(languageModelProperties.getLogRequests()) - .logResponses(languageModelProperties.getLogResponses()) - .customHeaders(languageModelProperties.getCustomHeaders()) + .baseUrl(languageModelProperties.baseUrl()) + .apiKey(languageModelProperties.apiKey()) + .organizationId(languageModelProperties.organizationId()) + .modelName(languageModelProperties.modelName()) + .temperature(languageModelProperties.temperature()) + .timeout(languageModelProperties.timeout()) + .proxy(ProxyProperties.convert(languageModelProperties.proxy())) + .logRequests(languageModelProperties.logRequests()) + .logResponses(languageModelProperties.logResponses()) + .customHeaders(languageModelProperties.customHeaders()) .build(); } @Bean @ConditionalOnProperty(PREFIX + ".embedding-model.api-key") OpenAiEmbeddingModel openAiEmbeddingModel(Properties properties) { - EmbeddingModelProperties embeddingModelProperties = properties.getEmbeddingModel(); + EmbeddingModelProperties embeddingModelProperties = properties.embeddingModel(); return OpenAiEmbeddingModel.builder() - .baseUrl(embeddingModelProperties.getBaseUrl()) - .apiKey(embeddingModelProperties.getApiKey()) - .organizationId(embeddingModelProperties.getOrganizationId()) - .modelName(embeddingModelProperties.getModelName()) - .dimensions(embeddingModelProperties.getDimensions()) - .user(embeddingModelProperties.getUser()) - .timeout(embeddingModelProperties.getTimeout()) - .maxRetries(embeddingModelProperties.getMaxRetries()) - .proxy(ProxyProperties.convert(embeddingModelProperties.getProxy())) - .logRequests(embeddingModelProperties.getLogRequests()) - .logResponses(embeddingModelProperties.getLogResponses()) - .customHeaders(embeddingModelProperties.getCustomHeaders()) + .baseUrl(embeddingModelProperties.baseUrl()) + .apiKey(embeddingModelProperties.apiKey()) + .organizationId(embeddingModelProperties.organizationId()) + .modelName(embeddingModelProperties.modelName()) + .dimensions(embeddingModelProperties.dimensions()) + .user(embeddingModelProperties.user()) + .timeout(embeddingModelProperties.timeout()) + .maxRetries(embeddingModelProperties.maxRetries()) + .proxy(ProxyProperties.convert(embeddingModelProperties.proxy())) + .logRequests(embeddingModelProperties.logRequests()) + .logResponses(embeddingModelProperties.logResponses()) + .customHeaders(embeddingModelProperties.customHeaders()) .build(); } @Bean @ConditionalOnProperty(PREFIX + ".moderation-model.api-key") OpenAiModerationModel openAiModerationModel(Properties properties) { - ModerationModelProperties moderationModelProperties = properties.getModerationModel(); + ModerationModelProperties moderationModelProperties = properties.moderationModel(); return OpenAiModerationModel.builder() - .baseUrl(moderationModelProperties.getBaseUrl()) - .apiKey(moderationModelProperties.getApiKey()) - .organizationId(moderationModelProperties.getOrganizationId()) - .modelName(moderationModelProperties.getModelName()) - .timeout(moderationModelProperties.getTimeout()) - .maxRetries(moderationModelProperties.getMaxRetries()) - .proxy(ProxyProperties.convert(moderationModelProperties.getProxy())) - .logRequests(moderationModelProperties.getLogRequests()) - .logResponses(moderationModelProperties.getLogResponses()) - .customHeaders(moderationModelProperties.getCustomHeaders()) + .baseUrl(moderationModelProperties.baseUrl()) + .apiKey(moderationModelProperties.apiKey()) + .organizationId(moderationModelProperties.organizationId()) + .modelName(moderationModelProperties.modelName()) + .timeout(moderationModelProperties.timeout()) + .maxRetries(moderationModelProperties.maxRetries()) + .proxy(ProxyProperties.convert(moderationModelProperties.proxy())) + .logRequests(moderationModelProperties.logRequests()) + .logResponses(moderationModelProperties.logResponses()) + .customHeaders(moderationModelProperties.customHeaders()) .build(); } @Bean @ConditionalOnProperty(PREFIX + ".image-model.api-key") OpenAiImageModel openAiImageModel(Properties properties) { - ImageModelProperties imageModelProperties = properties.getImageModel(); + ImageModelProperties imageModelProperties = properties.imageModel(); return OpenAiImageModel.builder() - .baseUrl(imageModelProperties.getBaseUrl()) - .apiKey(imageModelProperties.getApiKey()) - .organizationId(imageModelProperties.getOrganizationId()) - .modelName(imageModelProperties.getModelName()) - .size(imageModelProperties.getSize()) - .quality(imageModelProperties.getQuality()) - .style(imageModelProperties.getStyle()) - .user(imageModelProperties.getUser()) - .responseFormat(imageModelProperties.getResponseFormat()) - .timeout(imageModelProperties.getTimeout()) - .maxRetries(imageModelProperties.getMaxRetries()) - .proxy(ProxyProperties.convert(imageModelProperties.getProxy())) - .logRequests(imageModelProperties.getLogRequests()) - .logResponses(imageModelProperties.getLogResponses()) - .withPersisting(imageModelProperties.getWithPersisting()) - .persistTo(imageModelProperties.getPersistTo()) - .customHeaders(imageModelProperties.getCustomHeaders()) + .baseUrl(imageModelProperties.baseUrl()) + .apiKey(imageModelProperties.apiKey()) + .organizationId(imageModelProperties.organizationId()) + .modelName(imageModelProperties.modelName()) + .size(imageModelProperties.size()) + .quality(imageModelProperties.quality()) + .style(imageModelProperties.style()) + .user(imageModelProperties.user()) + .responseFormat(imageModelProperties.responseFormat()) + .timeout(imageModelProperties.timeout()) + .maxRetries(imageModelProperties.maxRetries()) + .proxy(ProxyProperties.convert(imageModelProperties.proxy())) + .logRequests(imageModelProperties.logRequests()) + .logResponses(imageModelProperties.logResponses()) + .withPersisting(imageModelProperties.withPersisting()) + .persistTo(imageModelProperties.persistTo()) + .customHeaders(imageModelProperties.customHeaders()) .build(); } diff --git a/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/ChatModelProperties.java b/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/ChatModelProperties.java index 4277630a..f6cfa16d 100644 --- a/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/ChatModelProperties.java +++ b/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/ChatModelProperties.java @@ -1,40 +1,37 @@ package dev.langchain4j.openai.spring; -import lombok.Getter; -import lombok.Setter; import org.springframework.boot.context.properties.NestedConfigurationProperty; import java.time.Duration; import java.util.List; import java.util.Map; -@Getter -@Setter -class ChatModelProperties { +record ChatModelProperties( - String baseUrl; - String apiKey; - String organizationId; - String modelName; - Double temperature; - Double topP; - List stop; - Integer maxTokens; - Integer maxCompletionTokens; - Double presencePenalty; - Double frequencyPenalty; - Map logitBias; - String responseFormat; - Boolean strictJsonSchema; - Integer seed; - String user; - Boolean strictTools; - Boolean parallelToolCalls; - Duration timeout; - Integer maxRetries; + String baseUrl, + String apiKey, + String organizationId, + String modelName, + Double temperature, + Double topP, + List stop, + Integer maxTokens, + Integer maxCompletionTokens, + Double presencePenalty, + Double frequencyPenalty, + Map logitBias, + String responseFormat, + Boolean strictJsonSchema, + Integer seed, + String user, + Boolean strictTools, + Boolean parallelToolCalls, + Duration timeout, + Integer maxRetries, @NestedConfigurationProperty - ProxyProperties proxy; - Boolean logRequests; - Boolean logResponses; - Map customHeaders; + ProxyProperties proxy, + Boolean logRequests, + Boolean logResponses, + Map customHeaders +) { } \ No newline at end of file diff --git a/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/EmbeddingModelProperties.java b/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/EmbeddingModelProperties.java index fa6b2157..381d0f34 100644 --- a/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/EmbeddingModelProperties.java +++ b/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/EmbeddingModelProperties.java @@ -1,27 +1,26 @@ package dev.langchain4j.openai.spring; -import lombok.Getter; -import lombok.Setter; import org.springframework.boot.context.properties.NestedConfigurationProperty; import java.time.Duration; import java.util.Map; -@Getter -@Setter -class EmbeddingModelProperties { - String baseUrl; - String apiKey; - String organizationId; - String modelName; - Integer dimensions; - String user; - Duration timeout; - Integer maxRetries; +record EmbeddingModelProperties( + + String baseUrl, + String apiKey, + String organizationId, + String modelName, + Integer dimensions, + String user, + Duration timeout, + Integer maxRetries, @NestedConfigurationProperty - ProxyProperties proxy; - Boolean logRequests; - Boolean logResponses; - Map customHeaders; + ProxyProperties proxy, + Boolean logRequests, + Boolean logResponses, + Map customHeaders +) { + } \ No newline at end of file diff --git a/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/ImageModelProperties.java b/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/ImageModelProperties.java index 793128f0..3d1666fe 100644 --- a/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/ImageModelProperties.java +++ b/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/ImageModelProperties.java @@ -1,33 +1,31 @@ package dev.langchain4j.openai.spring; -import lombok.Getter; -import lombok.Setter; import org.springframework.boot.context.properties.NestedConfigurationProperty; import java.nio.file.Path; import java.time.Duration; import java.util.Map; -@Getter -@Setter -class ImageModelProperties { - String baseUrl; - String apiKey; - String organizationId; - String modelName; - String size; - String quality; - String style; - String user; - String responseFormat; - Duration timeout; - Integer maxRetries; +record ImageModelProperties( + + String baseUrl, + String apiKey, + String organizationId, + String modelName, + String size, + String quality, + String style, + String user, + String responseFormat, + Duration timeout, + Integer maxRetries, @NestedConfigurationProperty - ProxyProperties proxy; - Boolean logRequests; - Boolean logResponses; - Boolean withPersisting; - Path persistTo; - Map customHeaders; + ProxyProperties proxy, + Boolean logRequests, + Boolean logResponses, + Boolean withPersisting, + Path persistTo, + Map customHeaders +) { } \ No newline at end of file diff --git a/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/LanguageModelProperties.java b/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/LanguageModelProperties.java index 6e8bb55b..fa245c2b 100644 --- a/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/LanguageModelProperties.java +++ b/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/LanguageModelProperties.java @@ -1,26 +1,24 @@ package dev.langchain4j.openai.spring; -import lombok.Getter; -import lombok.Setter; import org.springframework.boot.context.properties.NestedConfigurationProperty; import java.time.Duration; import java.util.Map; -@Getter -@Setter -class LanguageModelProperties { - String baseUrl; - String apiKey; - String organizationId; - String modelName; - Double temperature; - Duration timeout; - Integer maxRetries; +record LanguageModelProperties( + + String baseUrl, + String apiKey, + String organizationId, + String modelName, + Double temperature, + Duration timeout, + Integer maxRetries, @NestedConfigurationProperty - ProxyProperties proxy; - Boolean logRequests; - Boolean logResponses; - Map customHeaders; + ProxyProperties proxy, + Boolean logRequests, + Boolean logResponses, + Map customHeaders +) { } \ No newline at end of file diff --git a/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/ModerationModelProperties.java b/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/ModerationModelProperties.java index 219011f7..d1b0bc2e 100644 --- a/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/ModerationModelProperties.java +++ b/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/ModerationModelProperties.java @@ -1,25 +1,22 @@ package dev.langchain4j.openai.spring; -import lombok.Getter; -import lombok.Setter; import org.springframework.boot.context.properties.NestedConfigurationProperty; import java.time.Duration; import java.util.Map; -@Getter -@Setter -class ModerationModelProperties { +record ModerationModelProperties( - String baseUrl; - String apiKey; - String organizationId; - String modelName; - Duration timeout; - Integer maxRetries; + String baseUrl, + String apiKey, + String organizationId, + String modelName, + Duration timeout, + Integer maxRetries, @NestedConfigurationProperty - ProxyProperties proxy; - Boolean logRequests; - Boolean logResponses; - Map customHeaders; + ProxyProperties proxy, + Boolean logRequests, + Boolean logResponses, + Map customHeaders +) { } \ No newline at end of file diff --git a/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/Properties.java b/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/Properties.java index 8cd88766..d7483be6 100644 --- a/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/Properties.java +++ b/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/Properties.java @@ -1,35 +1,32 @@ package dev.langchain4j.openai.spring; -import lombok.Getter; -import lombok.Setter; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.NestedConfigurationProperty; -@Getter -@Setter @ConfigurationProperties(prefix = Properties.PREFIX) -public class Properties { - - static final String PREFIX = "langchain4j.open-ai"; +public record Properties( @NestedConfigurationProperty - ChatModelProperties chatModel; + ChatModelProperties chatModel, @NestedConfigurationProperty - ChatModelProperties streamingChatModel; + ChatModelProperties streamingChatModel, @NestedConfigurationProperty - LanguageModelProperties languageModel; + LanguageModelProperties languageModel, @NestedConfigurationProperty - LanguageModelProperties streamingLanguageModel; + LanguageModelProperties streamingLanguageModel, @NestedConfigurationProperty - EmbeddingModelProperties embeddingModel; + EmbeddingModelProperties embeddingModel, @NestedConfigurationProperty - ModerationModelProperties moderationModel; + ModerationModelProperties moderationModel, @NestedConfigurationProperty - ImageModelProperties imageModel; + ImageModelProperties imageModel +) { + static final String PREFIX = "langchain4j.open-ai"; + } diff --git a/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/ProxyProperties.java b/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/ProxyProperties.java index 141af329..14d8c2bc 100644 --- a/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/ProxyProperties.java +++ b/langchain4j-open-ai-spring-boot-starter/src/main/java/dev/langchain4j/openai/spring/ProxyProperties.java @@ -1,18 +1,15 @@ package dev.langchain4j.openai.spring; -import lombok.Getter; -import lombok.Setter; import java.net.InetSocketAddress; import java.net.Proxy; -@Getter -@Setter -class ProxyProperties { +record ProxyProperties( - Proxy.Type type; - String host; - Integer port; + Proxy.Type type, + String host, + Integer port +){ static Proxy convert(ProxyProperties proxy) { if (proxy == null) {