Skip to content

Commit 06ad198

Browse files
committed
dependencies: upgrade to Spring AI 1.0.0
1 parent e58d0e4 commit 06ad198

File tree

5 files changed

+68
-9
lines changed

5 files changed

+68
-9
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@ docs/build/
3939
/out/
4040
build/
4141
.gradle/
42+
compile_debug.log

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ elementaryVersion = 2.0.1
1818
gsonVersion = 2.10.1
1919
djlStarterVersion = 0.26
2020
djlVersion = 0.30.0
21-
springAiVersion = 1.0.0-M8
21+
springAiVersion = 1.0.0
2222
azureIdentityVersion = 1.15.4

redis-om-spring-ai/src/main/java/com/redis/om/spring/AIRedisConfiguration.java

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
import org.springframework.context.annotation.Configuration;
1515
import org.springframework.context.annotation.Primary;
1616
import org.springframework.lang.Nullable;
17+
import org.springframework.web.client.DefaultResponseErrorHandler;
18+
import org.springframework.web.client.ResponseErrorHandler;
19+
import org.springframework.web.client.RestClient;
20+
import org.springframework.web.reactive.function.client.WebClient;
21+
import io.micrometer.observation.ObservationRegistry;
1722

1823
import com.redis.om.spring.vectorize.DefaultEmbedder;
1924
import com.redis.om.spring.vectorize.Embedder;
@@ -79,9 +84,40 @@ public class AIRedisConfiguration {
7984
//// }
8085

8186
@Bean
82-
public EmbeddingModelFactory embeddingModelFactory(AIRedisOMProperties properties,
83-
SpringAiProperties springAiProperties) {
84-
return new EmbeddingModelFactory(properties, springAiProperties);
87+
public RestClient.Builder restClientBuilder() {
88+
return RestClient.builder();
89+
}
90+
91+
@Bean
92+
public WebClient.Builder webClientBuilder() {
93+
return WebClient.builder();
94+
}
95+
96+
@Bean
97+
public ResponseErrorHandler defaultResponseErrorHandler() {
98+
return new DefaultResponseErrorHandler();
99+
}
100+
101+
@Bean
102+
public ObservationRegistry observationRegistry() {
103+
return ObservationRegistry.create();
104+
}
105+
106+
@Bean
107+
public EmbeddingModelFactory embeddingModelFactory(
108+
AIRedisOMProperties properties,
109+
SpringAiProperties springAiProperties,
110+
RestClient.Builder restClientBuilder,
111+
WebClient.Builder webClientBuilder,
112+
ResponseErrorHandler responseErrorHandler,
113+
ObservationRegistry observationRegistry) {
114+
return new EmbeddingModelFactory(
115+
properties,
116+
springAiProperties,
117+
restClientBuilder,
118+
webClientBuilder,
119+
responseErrorHandler,
120+
observationRegistry);
85121
}
86122

87123
@Bean(

redis-om-spring-ai/src/main/java/com/redis/om/spring/vectorize/EmbeddingModelFactory.java

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727
import org.springframework.ai.vertexai.embedding.text.VertexAiTextEmbeddingOptions;
2828
import org.springframework.http.client.SimpleClientHttpRequestFactory;
2929
import org.springframework.util.StringUtils;
30+
import org.springframework.web.client.ResponseErrorHandler;
3031
import org.springframework.web.client.RestClient;
32+
import org.springframework.web.reactive.function.client.WebClient;
33+
import io.micrometer.observation.ObservationRegistry;
3134

3235
import com.azure.ai.openai.OpenAIClient;
3336
import com.azure.ai.openai.OpenAIClientBuilder;
@@ -43,10 +46,24 @@
4346
public class EmbeddingModelFactory {
4447
private final AIRedisOMProperties properties;
4548
private final SpringAiProperties springAiProperties;
46-
47-
public EmbeddingModelFactory(AIRedisOMProperties properties, SpringAiProperties springAiProperties) {
49+
private final RestClient.Builder restClientBuilder;
50+
private final WebClient.Builder webClientBuilder;
51+
private final ResponseErrorHandler responseErrorHandler;
52+
private final ObservationRegistry observationRegistry;
53+
54+
public EmbeddingModelFactory(
55+
AIRedisOMProperties properties,
56+
SpringAiProperties springAiProperties,
57+
RestClient.Builder restClientBuilder,
58+
WebClient.Builder webClientBuilder,
59+
ResponseErrorHandler responseErrorHandler,
60+
ObservationRegistry observationRegistry) {
4861
this.properties = properties;
4962
this.springAiProperties = springAiProperties;
63+
this.restClientBuilder = restClientBuilder;
64+
this.webClientBuilder = webClientBuilder;
65+
this.responseErrorHandler = responseErrorHandler;
66+
this.observationRegistry = observationRegistry;
5067
}
5168

5269
public TransformersEmbeddingModel createTransformersEmbeddingModel(Vectorize vectorize) {
@@ -174,7 +191,12 @@ public VertexAiTextEmbeddingModel createVertexAiTextEmbeddingModel(String model)
174191
}
175192

176193
public OllamaEmbeddingModel createOllamaEmbeddingModel(String model) {
177-
OllamaApi api = new OllamaApi(properties.getOllama().getBaseUrl());
194+
OllamaApi api = OllamaApi.builder()
195+
.baseUrl(properties.getOllama().getBaseUrl())
196+
.restClientBuilder(restClientBuilder)
197+
.webClientBuilder(webClientBuilder)
198+
.responseErrorHandler(responseErrorHandler)
199+
.build();
178200

179201
OllamaOptions options = OllamaOptions.builder().model(model).truncate(false).build();
180202

@@ -228,6 +250,6 @@ public BedrockTitanEmbeddingModel createTitanEmbeddingModel(String model) {
228250
properties.getAws().getRegion(), ModelOptionsUtils.OBJECT_MAPPER, Duration.ofMinutes(properties.getAws()
229251
.getBedrockTitan().getResponseTimeOut()));
230252

231-
return new BedrockTitanEmbeddingModel(titanEmbeddingApi);
253+
return new BedrockTitanEmbeddingModel(titanEmbeddingApi, observationRegistry);
232254
}
233255
}

redis-om-spring/src/main/java/com/redis/om/spring/RedisEnhancedKeyValueAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ private <T> T readTimeToLiveIfSet(@Nullable byte[] key, @Nullable T target) {
498498
}
499499

500500
RedisPersistentEntity<?> entity = this.converter.getMappingContext().getRequiredPersistentEntity(target.getClass());
501-
if (entity.hasExplictTimeToLiveProperty()) {
501+
if (entity.hasExplicitTimeToLiveProperty()) {
502502

503503
RedisPersistentProperty ttlProperty = entity.getExplicitTimeToLiveProperty();
504504
if (ttlProperty == null) {

0 commit comments

Comments
 (0)