Retrieve semantically relevant passages for a question and run a parallel ranked query to enrich a RAG context.
1 workflow1 source API1 provider
View SpecView on GitHubArtificial IntelligenceAmazon Web ServicesEnterprise SearchKnowledge ManagementMachine LearningNatural-LanguageSearchArazzoWorkflows
arazzo: 1.0.1
info:
title: Amazon Kendra Retrieve Passages for RAG
summary: Retrieve semantically relevant passages for a question and run a parallel ranked query to enrich a RAG context.
description: >-
Builds the context for a retrieval-augmented-generation prompt by calling
Retrieve to pull the most relevant text passages for an input question, then
running a standard Query for the same text to capture ranked document results
and any extractive answers. Combining both gives a downstream LLM both long
passages and short ranked answers. Each step inlines its request, including
the AWS JSON protocol X-Amz-Target header, so the flow can be read and
executed without opening the underlying OpenAPI description.
version: 1.0.0
sourceDescriptions:
- name: queriesApi
url: ../openapi/amazon-kendra-queries-api-openapi.yml
type: openapi
workflows:
- workflowId: retrieve-passages-for-rag
summary: Retrieve passages and run a ranked query for the same question.
description: >-
Retrieves relevant passages for an input question and runs a parallel ranked
query, assembling both into a combined context for RAG.
inputs:
type: object
required:
- indexId
- queryText
properties:
indexId:
type: string
description: The identifier of the index to retrieve from.
queryText:
type: string
description: The question to retrieve passages and ranked results for.
attributeFilter:
type: object
description: Optional attribute filter to scope results.
pageSize:
type: integer
description: Optional number of results per page.
steps:
- stepId: retrievePassages
description: >-
Retrieve the most relevant text passages for the input question for use as
grounding context in a RAG prompt.
operationId: Retrieve
parameters:
- name: X-Amz-Target
in: header
value: AWSKendraFrontendService.Retrieve
requestBody:
contentType: application/json
payload:
QueryText: $inputs.queryText
AttributeFilter: $inputs.attributeFilter
PageSize: $inputs.pageSize
IndexId: $inputs.indexId
successCriteria:
- condition: $statusCode == 200
outputs:
queryId: $response.body#/QueryId
resultItems: $response.body#/ResultItems
- stepId: rankedQuery
description: >-
Run a standard ranked query for the same question to capture extractive
answers and ranked document results alongside the retrieved passages.
operationId: Query
parameters:
- name: X-Amz-Target
in: header
value: AWSKendraFrontendService.Query
requestBody:
contentType: application/json
payload:
QueryText: $inputs.queryText
AttributeFilter: $inputs.attributeFilter
PageSize: $inputs.pageSize
IndexId: $inputs.indexId
successCriteria:
- condition: $statusCode == 200
outputs:
queryId: $response.body#/QueryId
resultItems: $response.body#/ResultItems
totalResults: $response.body#/TotalNumberOfResults
outputs:
retrievedPassages: $steps.retrievePassages.outputs.resultItems
rankedResults: $steps.rankedQuery.outputs.resultItems
totalResults: $steps.rankedQuery.outputs.totalResults
Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Get an API key
Free tier, no form to fill in. Signing in shares your email address with us — we
store it to create your key and to recognise you if you sign in with another
provider. By signing up you are subscribing to the APIs.io and API Evangelist
newsletters — you can unsubscribe from any issue. See our
Privacy Policy and Terms.