Retrieves information from one or more knowledge bases using an agentic approach¶
Description¶
Retrieves information from one or more knowledge bases using an agentic approach. Agentic retrieval uses a foundation model to intelligently decompose complex queries into sub-queries and iteratively retrieve relevant information from your knowledge bases. This approach improves retrieval accuracy for complex, multi-step questions that a single retrieval pass might not fully address.
The operation returns results through a stream that includes retrieval results, trace events for visibility into the process, and a generated response synthesized from the results by default, which can be turned off.
Usage¶
bedrockagentruntime_agentic_retrieve_stream(
agenticRetrieveConfiguration, generateResponse, memoryConfiguration,
messages, nextToken, policyConfiguration, retrievers, userContext)
Arguments¶
agenticRetrieveConfiguration
[required] Configuration settings for the agentic retrieval operation.
generateResponse
Whether to generate a response based on the retrieved results.
memoryConfiguration
The configuration for using an Amazon Bedrock AgentCore Memory resource with this retrieval.
messages
[required] The list of messages for the agentic retrieval conversation.
nextToken
Opaque continuation token for paginated results.
policyConfiguration
Policy configuration for guardrails and content filtering.
retrievers
[required] The list of retrievers to use for agentic retrieval.
userContext
Contains information about the user making the request. This is used for access control filtering to ensure that retrieval results only include documents the user is authorized to access.
Value¶
A list with the following syntax:
list(
stream = list(
accessDeniedException = list(
message = "string"
),
badGatewayException = list(
message = "string",
resourceName = "string"
),
conflictException = list(
message = "string"
),
dependencyFailedException = list(
message = "string",
resourceName = "string"
),
internalServerException = list(
message = "string",
reason = "string"
),
resourceNotFoundException = list(
message = "string"
),
responseEvent = list(
text = "string"
),
result = list(
generatedResponse = list(
answer = "string",
citations = list(
list(
endIndex = 123,
references = list(
list(
resultIndex = 123
)
),
startIndex = 123
)
)
),
nextToken = "string",
results = list(
list(
content = list(
byteContent = raw,
mimeType = "string",
text = "string"
),
metadata = list(
list()
),
sourceRetriever = list(
identifier = "string"
)
)
)
),
serviceQuotaExceededException = list(
message = "string"
),
throttlingException = list(
message = "string"
),
traceEvent = list(
attributes = list(
actions = list(
list(
fullDocumentExpansion = list(
documentId = "string",
sourceRetriever = list(
identifier = "string"
)
),
memoryRetrieve = list(
inputQuery = list(
text = "string"
),
memoryId = "string",
namespace = "string",
namespacePath = "string",
strategyId = "string"
),
retrieve = list(
inputQuery = list(
text = "string"
),
sourceRetrievers = list(
list(
identifier = "string"
)
)
)
)
),
failures = list(
list(
message = "string"
)
),
message = "string",
retrievalMetadata = list(
list(
identifier = "string",
retrievalType = "BedrockKnowledgeBase"|"BedrockAgentCoreMemory"
)
),
retrievalResponse = list(
list(
content = list(
byteContent = raw,
mimeType = "string",
text = "string"
),
metadata = list(
list()
),
sourceRetriever = list(
identifier = "string"
)
)
),
status = "IN_PROGRESS"|"SUCCEEDED"|"FAILED",
step = "Planning"|"Retrieval"|"SpeculativeRetrieval"|"FullDocumentExpansion"|"SessionHistoryLoad",
warnings = list(
list(
guardrail = list(
action = "INTERVENED"|"NONE",
id = "string",
message = "string",
version = "string"
),
message = list(
message = "string"
)
)
)
),
id = "string",
timestamp = 123
),
validationException = list(
message = "string"
)
)
)
Request syntax¶
svc$agentic_retrieve_stream(
agenticRetrieveConfiguration = list(
foundationModelConfiguration = list(
bedrockFoundationModelConfiguration = list(
modelConfiguration = list(
modelArn = "string"
)
),
mantleFoundationModelConfiguration = list(
modelConfiguration = list(
modelArn = "string",
projectId = "string"
)
),
type = "BEDROCK_FOUNDATION_MODEL"|"MANTLE_FOUNDATION_MODEL"
),
foundationModelType = "CUSTOM"|"MANAGED",
maxAgentIteration = 123,
rerankingConfiguration = list(
bedrockRerankingConfiguration = list(
modelConfiguration = list(
modelArn = "string"
)
),
type = "BEDROCK_RERANKING_MODEL"
),
rerankingModelType = "CUSTOM"|"MANAGED"|"NONE"
),
generateResponse = TRUE|FALSE,
memoryConfiguration = list(
memoryId = "string",
persistenceMode = "DEFAULT"|"NONE",
retrievalConfigs = list(
list(
metadataFilters = list(
list(
left = list(
metadataKey = "string"
),
operator = "EQUALS_TO"|"EXISTS"|"NOT_EXISTS"|"BEFORE"|"AFTER"|"CONTAINS"|"GREATER_THAN"|"GREATER_THAN_OR_EQUALS"|"LESS_THAN"|"LESS_THAN_OR_EQUALS",
right = list(
metadataValue = list(
dateTimeValue = as.POSIXct(
"2015-01-01"
),
numberValue = 123.0,
stringListValue = list(
"string"
),
stringValue = "string"
)
)
)
),
namespace = "string",
namespacePath = "string",
strategyId = "string"
)
),
sessionBinding = list(
actorId = "string",
sessionId = "string"
)
),
messages = list(
list(
content = list(
text = "string"
),
role = "user"|"assistant"
)
),
nextToken = "string",
policyConfiguration = list(
bedrockGuardrailConfiguration = list(
guardrailId = "string",
guardrailVersion = "string"
)
),
retrievers = list(
list(
configuration = list(
knowledgeBase = list(
knowledgeBaseId = "string",
retrievalOverrides = list(
filter = list(
andAll = list(
list()
),
equals = list(
key = "string",
value = list()
),
greaterThan = list(
key = "string",
value = list()
),
greaterThanOrEquals = list(
key = "string",
value = list()
),
in = list(
key = "string",
value = list()
),
lessThan = list(
key = "string",
value = list()
),
lessThanOrEquals = list(
key = "string",
value = list()
),
listContains = list(
key = "string",
value = list()
),
notEquals = list(
key = "string",
value = list()
),
notIn = list(
key = "string",
value = list()
),
orAll = list(
list()
),
startsWith = list(
key = "string",
value = list()
),
stringContains = list(
key = "string",
value = list()
)
),
maxNumberOfResults = 123
)
)
),
description = "string"
)
),
userContext = list(
userId = "string"
)
)