Skip to content

Retrieved Context Transformation

After retrieving documents, you might want to transform the documents or generate better context.

The TransformResponse trait

The TransformResponse trait is defined as follows:

pub trait TransformResponse: Send + Sync {
async fn transform_response(&self, query: Query<Retrieved>)
-> Result<Query<states::Retrieved>>;
}

The transformer takes the current query, applies transformations, and returns the new query.

Closures are also supported in this step.

Built in query transformers

NameDescriptionFeature Flag
SummaryGenerates a summary of the current retrieved documents