Я пытаюсь сделать что-то, где у меня есть два советника: один представляет собой типичное векторное хранилище RAG для моего вопроса-ответа, а другой использует Redis для встраивания кеша вопросов. Исходный вариант QuestionAnswerAdvisor работает отлично, но когда я добавляю хранилище Redis, я не понимаю, как квалифицировать внедренный компонент, чтобы убедиться, что он использует Redis вместо сосновой шишки. Я попробовал это
@Bean(name = "openAiBuildClient")
public ChatClient buildClient(
@Qualifier("openAiChatClientBuilder") ChatClient.Builder openAiBuilder,
MessageChatMemoryAdvisor messageChatMemoryAdvisor,
RedisVectorStore redisVectorStore,
PineconeVectorStore pineconeVectorStore
) {
spring:
application:
name: "my-spring-ai"
ai:
vectorstore:
redis:
index: spring-ai-example
uri: redis://localhost:6379
pinecone:
apiKey: ${PINECONE_API_KEY}
index-name: spring-ai-example
Но это так не работает...
Description:
Parameter 2 of method buildClient in org.example.config.clients.OpenAIClientConfig required a bean of type 'org.springframework.ai.vectorstore.RedisVectorStore' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Qualifier("openAiBuildClient")
Так можно ли одновременно иметь несколько векторных хранилищ с помощью @Qualifier? Если да, то как это сделать?
Обновить
Похоже, именно поэтому оно не работает
RedisVectorStoreAutoConfiguration:
Did not match:
- @ConditionalOnBean (types: org.springframework.data.redis.connection.jedis.JedisConnectionFactory; SearchStrategy: all) did not find any beans of type org.springframework.data.redis.connection.jedis.JedisConnectionFactory (OnBeanCondition)
Matched:
- @ConditionalOnClass found required classes 'redis.clients.jedis.JedisPooled', 'org.springframework.data.redis.connection.jedis.JedisConnectionFactory', 'org.springframework.ai.vectorstore.RedisVectorStore', 'org.springframework.ai.embedding.EmbeddingModel' (OnClassCondition)
Но у меня есть
implementation "org.springframework.ai:spring-ai-redis-store-spring-boot-starter:${springAiVersion}"
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
Я тоже пробовал
implementation 'org.springframework.data:spring-data-redis'
Я также не вижу необходимости объявлять JedisConnectionFactory в документации Redis.
https://docs. Spring.io/spring-ai/reference/api/vectordbs/redis.html#_manual_configuration
Обновить 2, ок, вернемся к исходному вопросу
Я добавлен (хотя в документации это должно быть пропущено)
@Bean
public JedisConnectionFactory redisConnectionFactory() {
return new JedisConnectionFactory();
}
И теперь я получаю
Description:
The bean 'vectorStore', defined in class path resource [org/springframework/ai/autoconfigure/vectorstore/redis/RedisVectorStoreAutoConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/ai/autoconfigure/vectorstore/pinecone/PineconeVectorStoreAutoConfiguration.class] and overriding is disabled.
Подробнее здесь: https://stackoverflow.com/questions/792 ... -spring-ai
Как использовать Redis и иметь несколько хранилищ Vector в Spring AI? ⇐ JAVA
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение