Как использовать несколько VectorStore в Spring AI?JAVA

Программисты JAVA общаются здесь
Ответить
Anonymous
 Как использовать несколько VectorStore в Spring AI?

Сообщение Anonymous »

Я пытаюсь сделать что-то, где у меня есть два советника: один представляет собой типичное векторное хранилище 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'
и А

Подробнее здесь: https://stackoverflow.com/questions/792 ... -spring-ai
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «JAVA»