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 #2346

Open
magicgone-cn opened this issue Feb 28, 2025 · 0 comments · May be fixed by #2348
Open

Add Context Support to Query in RetrievalAugmentationAdvisor #2346

magicgone-cn opened this issue Feb 28, 2025 · 0 comments · May be fixed by #2348

Comments

@magicgone-cn
Copy link

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);
		}
...
}
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 a pull request may close this issue.

1 participant