Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to merge results from two vectorStore queries into one prompt context? #4538

Unanswered
marcelodl asked this question in Q&A
Discussion options

Hello everyone, I need some guidance.

I’m using a vectorStore and want to build a prompt that includes two distinct contexts, both retrieved from the vector store, for example:

Given the context below:
-----------------
<context1> // result set #1 from vectorStore (e.g., filter A / topK1)
-----------------
Write a document using the model below:
-----------------
<context2> // result set #2 from vectorStore (e.g., filter B / topK2)
-----------------

I’m currently using QuestionAnswerAdvisory like this:

chatClient.prompt()
 .advisors(advisorSpec -> advisorSpec
 .param(CONVERSATION_ID, id))
 .param(TOP_K, 100)
 .param(QuestionAnswerAdvisor.FILTER_EXPRESSION, "key == '" + key + "'")
;

What’s the recommended Spring AI pattern to run two separate vectorStore queries (with different filters/topK) and inject both result sets into a single prompt?

  • Is it possible to attach two QuestionAnswerAdvisors (one per filter) and have them both contribute to the final context?
  • Or should I run two queries manually (pre-prompt), then pass them as separate variables/sections in the prompt template (e.g., <context1> and <context2>) via prompt().param(...)?

Any code snippet or best practice for merging multiple retrievals into one prompt would be greatly appreciated. Thanks!

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /