Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Context Support to Query in RetrievalAugmentationAdvisor #2348

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

magicgone-cn
Copy link

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Context Support to Query in RetrievalAugmentationAdvisor
1 participant