Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of lombok for langchain4j-spring-boot-starter and langchain4j-open-ai-spring-boot-starter #49

Merged
merged 2 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions langchain4j-open-ai-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@
<optional>true</optional>
</dependency>

<!-- should be listed before spring-boot-configuration-processor -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>

<!-- needed to generate automatic metadata about available config properties -->
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -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<String> stop;
Integer maxTokens;
Integer maxCompletionTokens;
Double presencePenalty;
Double frequencyPenalty;
Map<String, Integer> 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<String> stop,
Integer maxTokens,
Integer maxCompletionTokens,
Double presencePenalty,
Double frequencyPenalty,
Map<String, Integer> 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<String, String> customHeaders;
ProxyProperties proxy,
Boolean logRequests,
Boolean logResponses,
Map<String, String> customHeaders
) {
}
Original file line number Diff line number Diff line change
@@ -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<String, String> customHeaders;
ProxyProperties proxy,
Boolean logRequests,
Boolean logResponses,
Map<String, String> customHeaders
) {

}
Original file line number Diff line number Diff line change
@@ -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<String, String> customHeaders;
ProxyProperties proxy,
Boolean logRequests,
Boolean logResponses,
Boolean withPersisting,
Path persistTo,
Map<String, String> customHeaders
) {
}
Original file line number Diff line number Diff line change
@@ -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<String, String> customHeaders;
ProxyProperties proxy,
Boolean logRequests,
Boolean logResponses,
Map<String, String> customHeaders
) {
}
Original file line number Diff line number Diff line change
@@ -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<String, String> customHeaders;
ProxyProperties proxy,
Boolean logRequests,
Boolean logResponses,
Map<String, String> customHeaders
) {
}
Original file line number Diff line number Diff line change
@@ -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";

}
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
7 changes: 0 additions & 7 deletions langchain4j-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@
<optional>true</optional>
</dependency>

<!-- should be listed before spring-boot-configuration-processor -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>

<!-- needed to generate automatic metadata about available config properties -->
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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) {
}