|
1 | 1 | package com.dotcms.ai.client.langchain4j; |
2 | 2 |
|
3 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
| 4 | +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; |
| 5 | +import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| 6 | +import org.immutables.value.Value; |
| 7 | + |
| 8 | +import javax.annotation.Nullable; |
4 | 9 |
|
5 | 10 | /** |
6 | | - * Deserializable POJO for a single provider section in the {@code providerConfig} JSON. |
| 11 | + * Immutable representation of a single provider section in the {@code providerConfig} JSON. |
7 | 12 | * |
8 | 13 | * <p>Each section (chat, embeddings, image) in the JSON maps to one instance of this class. |
9 | 14 | * Unknown fields are ignored to allow forward-compatible configuration. |
|
40 | 45 | * <li>{@code location}</li> |
41 | 46 | * </ul> |
42 | 47 | */ |
| 48 | +@Value.Immutable |
| 49 | +@JsonSerialize(as = ImmutableProviderConfig.class) |
| 50 | +@JsonDeserialize(as = ImmutableProviderConfig.class) |
43 | 51 | @JsonIgnoreProperties(ignoreUnknown = true) |
44 | | -public class ProviderConfig { |
| 52 | +public interface ProviderConfig { |
45 | 53 |
|
46 | | - private String provider; |
47 | | - private String model; |
48 | | - private Integer maxTokens; |
49 | | - private Integer maxCompletionTokens; |
50 | | - private Double temperature; |
51 | | - private Integer maxRetries; |
52 | | - private Integer timeout; |
| 54 | + @Nullable String provider(); |
| 55 | + @Nullable String model(); |
| 56 | + @Nullable Integer maxTokens(); |
| 57 | + @Nullable Integer maxCompletionTokens(); |
| 58 | + @Nullable Double temperature(); |
| 59 | + @Nullable Integer maxRetries(); |
| 60 | + @Nullable Integer timeout(); |
53 | 61 |
|
54 | 62 | // OpenAI / Azure OpenAI |
55 | | - private String apiKey; |
56 | | - private String size; |
57 | | - private String endpoint; |
58 | | - private String deploymentName; |
59 | | - private String apiVersion; |
| 63 | + @Nullable String apiKey(); |
| 64 | + @Nullable String size(); |
| 65 | + @Nullable String endpoint(); |
| 66 | + @Nullable String deploymentName(); |
| 67 | + @Nullable String apiVersion(); |
60 | 68 |
|
61 | 69 | // AWS Bedrock |
62 | | - private String region; |
63 | | - private String accessKeyId; |
64 | | - private String secretAccessKey; |
| 70 | + @Nullable String region(); |
| 71 | + @Nullable String accessKeyId(); |
| 72 | + @Nullable String secretAccessKey(); |
65 | 73 |
|
66 | 74 | // Google Vertex AI |
67 | | - private String projectId; |
68 | | - private String location; |
69 | | - |
70 | | - public String getProvider() { |
71 | | - return provider; |
72 | | - } |
73 | | - |
74 | | - public void setProvider(final String provider) { |
75 | | - this.provider = provider; |
76 | | - } |
77 | | - |
78 | | - public String getModel() { |
79 | | - return model; |
80 | | - } |
81 | | - |
82 | | - public void setModel(final String model) { |
83 | | - this.model = model; |
84 | | - } |
85 | | - |
86 | | - public Integer getMaxTokens() { |
87 | | - return maxTokens; |
88 | | - } |
89 | | - |
90 | | - public void setMaxTokens(final Integer maxTokens) { |
91 | | - this.maxTokens = maxTokens; |
92 | | - } |
93 | | - |
94 | | - public Integer getMaxCompletionTokens() { |
95 | | - return maxCompletionTokens; |
96 | | - } |
97 | | - |
98 | | - public void setMaxCompletionTokens(final Integer maxCompletionTokens) { |
99 | | - this.maxCompletionTokens = maxCompletionTokens; |
100 | | - } |
101 | | - |
102 | | - public Double getTemperature() { |
103 | | - return temperature; |
104 | | - } |
105 | | - |
106 | | - public void setTemperature(final Double temperature) { |
107 | | - this.temperature = temperature; |
108 | | - } |
109 | | - |
110 | | - public Integer getMaxRetries() { |
111 | | - return maxRetries; |
112 | | - } |
113 | | - |
114 | | - public void setMaxRetries(final Integer maxRetries) { |
115 | | - this.maxRetries = maxRetries; |
116 | | - } |
117 | | - |
118 | | - public Integer getTimeout() { |
119 | | - return timeout; |
120 | | - } |
121 | | - |
122 | | - public void setTimeout(final Integer timeout) { |
123 | | - this.timeout = timeout; |
124 | | - } |
125 | | - |
126 | | - public String getApiKey() { |
127 | | - return apiKey; |
128 | | - } |
129 | | - |
130 | | - public void setApiKey(final String apiKey) { |
131 | | - this.apiKey = apiKey; |
132 | | - } |
133 | | - |
134 | | - public String getSize() { |
135 | | - return size; |
136 | | - } |
137 | | - |
138 | | - public void setSize(final String size) { |
139 | | - this.size = size; |
140 | | - } |
141 | | - |
142 | | - public String getEndpoint() { |
143 | | - return endpoint; |
144 | | - } |
145 | | - |
146 | | - public void setEndpoint(final String endpoint) { |
147 | | - this.endpoint = endpoint; |
148 | | - } |
149 | | - |
150 | | - public String getDeploymentName() { |
151 | | - return deploymentName; |
152 | | - } |
153 | | - |
154 | | - public void setDeploymentName(final String deploymentName) { |
155 | | - this.deploymentName = deploymentName; |
156 | | - } |
157 | | - |
158 | | - public String getApiVersion() { |
159 | | - return apiVersion; |
160 | | - } |
161 | | - |
162 | | - public void setApiVersion(final String apiVersion) { |
163 | | - this.apiVersion = apiVersion; |
164 | | - } |
165 | | - |
166 | | - public String getRegion() { |
167 | | - return region; |
168 | | - } |
169 | | - |
170 | | - public void setRegion(final String region) { |
171 | | - this.region = region; |
172 | | - } |
173 | | - |
174 | | - public String getAccessKeyId() { |
175 | | - return accessKeyId; |
176 | | - } |
177 | | - |
178 | | - public void setAccessKeyId(final String accessKeyId) { |
179 | | - this.accessKeyId = accessKeyId; |
180 | | - } |
181 | | - |
182 | | - public String getSecretAccessKey() { |
183 | | - return secretAccessKey; |
184 | | - } |
185 | | - |
186 | | - public void setSecretAccessKey(final String secretAccessKey) { |
187 | | - this.secretAccessKey = secretAccessKey; |
188 | | - } |
189 | | - |
190 | | - public String getProjectId() { |
191 | | - return projectId; |
192 | | - } |
193 | | - |
194 | | - public void setProjectId(final String projectId) { |
195 | | - this.projectId = projectId; |
196 | | - } |
197 | | - |
198 | | - public String getLocation() { |
199 | | - return location; |
200 | | - } |
201 | | - |
202 | | - public void setLocation(final String location) { |
203 | | - this.location = location; |
204 | | - } |
| 75 | + @Nullable String projectId(); |
| 76 | + @Nullable String location(); |
205 | 77 |
|
206 | 78 | } |
0 commit comments