Skip to content

Conversation

@magicgone-cn
Copy link
Contributor

@magicgone-cn magicgone-cn commented Feb 28, 2025

Currently, the Query object originalQuery in RetrievalAugmentationAdvisor only includes text and history fields. I wish to add context into originalQuery. By adding context support, downstream transformers and retrievers would be able to access more runtime information to enhance their processing capabilities.

RetrievalAugmentationAdvisor

public AdvisedRequest before(AdvisedRequest request) {
		Map<String, Object> context = new HashMap<>(request.adviseContext());

		// 0. Create a query from the user text, parameters, and conversation history.
		Query originalQuery = Query.builder()
			.text(new PromptTemplate(request.userText(), request.userParams()).render())
			.history(request.messages())
			.build();

		// 1. Transform original user query based on a chain of query transformers.
		Query transformedQuery = originalQuery;
		for (var queryTransformer : this.queryTransformers) {
			transformedQuery = queryTransformer.apply(transformedQuery);
		}
...
}

Resolves #2346

@ilayaperumalg ilayaperumalg self-assigned this Mar 10, 2025
@ilayaperumalg ilayaperumalg added the RAG Issues related to Retrieval Augmented Generation label Mar 10, 2025
@ilayaperumalg ilayaperumalg added this to the 1.0.0-M7 milestone Mar 10, 2025
@ilayaperumalg
Copy link
Member

@magicgone-cn Thanks for the PR! Rebased and merged as 206b9e2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RAG Issues related to Retrieval Augmented Generation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Context Support to Query in RetrievalAugmentationAdvisor

2 participants