2024/02/28 - Agents for Amazon Bedrock Runtime - 2 updated api methods
Changes This release adds support to override search strategy performed by the Retrieve and RetrieveAndGenerate APIs for Amazon Bedrock Agents
{'retrievalConfiguration': {'vectorSearchConfiguration': {'overrideSearchType': 'HYBRID '
'| '
'SEMANTIC'}}}
Retrieve from knowledge base.
See also: AWS API Documentation
Request Syntax
client.retrieve(
knowledgeBaseId='string',
retrievalQuery={
'text': 'string'
},
retrievalConfiguration={
'vectorSearchConfiguration': {
'numberOfResults': 123,
'overrideSearchType': 'HYBRID'|'SEMANTIC'
}
},
nextToken='string'
)
string
[REQUIRED]
Identifier of the KnowledgeBase
dict
[REQUIRED]
Knowledge base input query.
text (string) -- [REQUIRED]
Knowledge base input query in text
dict
Search parameters for retrieving from knowledge base.
vectorSearchConfiguration (dict) -- [REQUIRED]
Knowledge base vector search configuration
numberOfResults (integer) --
Top-K results to retrieve from knowledge base.
overrideSearchType (string) --
Override the type of query to be performed on data store
string
Opaque continuation token of previous paginated response.
dict
Response Syntax
{
'retrievalResults': [
{
'content': {
'text': 'string'
},
'location': {
'type': 'S3',
's3Location': {
'uri': 'string'
}
},
'score': 123.0
},
],
'nextToken': 'string'
}
Response Structure
(dict) --
retrievalResults (list) --
List of knowledge base retrieval results
(dict) --
Result item returned from a knowledge base retrieval.
content (dict) --
Content of a retrieval result.
text (string) --
Content of a retrieval result in text
location (dict) --
The source location of a retrieval result.
type (string) --
The location type of a retrieval result.
s3Location (dict) --
The S3 location of a retrieval result.
uri (string) --
URI of S3 location
score (float) --
The relevance score of a result.
nextToken (string) --
Opaque continuation token of previous paginated response.
{'retrieveAndGenerateConfiguration': {'knowledgeBaseConfiguration': {'retrievalConfiguration': {'vectorSearchConfiguration': {'numberOfResults': 'integer',
'overrideSearchType': 'HYBRID '
'| '
'SEMANTIC'}}}}}
RetrieveAndGenerate API
See also: AWS API Documentation
Request Syntax
client.retrieve_and_generate(
sessionId='string',
input={
'text': 'string'
},
retrieveAndGenerateConfiguration={
'type': 'KNOWLEDGE_BASE',
'knowledgeBaseConfiguration': {
'knowledgeBaseId': 'string',
'modelArn': 'string',
'retrievalConfiguration': {
'vectorSearchConfiguration': {
'numberOfResults': 123,
'overrideSearchType': 'HYBRID'|'SEMANTIC'
}
}
}
},
sessionConfiguration={
'kmsKeyArn': 'string'
}
)
string
Identifier of the session.
dict
[REQUIRED]
Customer input of the turn
text (string) -- [REQUIRED]
Customer input of the turn in text
dict
Configures the retrieval and generation for the session.
type (string) -- [REQUIRED]
The type of RetrieveAndGenerate.
knowledgeBaseConfiguration (dict) --
Configurations for retrieval and generation for knowledge base.
knowledgeBaseId (string) -- [REQUIRED]
Identifier of the KnowledgeBase
modelArn (string) -- [REQUIRED]
Arn of a Bedrock model.
retrievalConfiguration (dict) --
Search parameters for retrieving from knowledge base.
vectorSearchConfiguration (dict) -- [REQUIRED]
Knowledge base vector search configuration
numberOfResults (integer) --
Top-K results to retrieve from knowledge base.
overrideSearchType (string) --
Override the type of query to be performed on data store
dict
Configures common parameters of the session.
kmsKeyArn (string) -- [REQUIRED]
The KMS key arn to encrypt the customer data of the session.
dict
Response Syntax
{
'sessionId': 'string',
'output': {
'text': 'string'
},
'citations': [
{
'generatedResponsePart': {
'textResponsePart': {
'text': 'string',
'span': {
'start': 123,
'end': 123
}
}
},
'retrievedReferences': [
{
'content': {
'text': 'string'
},
'location': {
'type': 'S3',
's3Location': {
'uri': 'string'
}
}
},
]
},
]
}
Response Structure
(dict) --
sessionId (string) --
Identifier of the session.
output (dict) --
Service response of the turn
text (string) --
Service response of the turn in text
citations (list) --
List of citations
(dict) --
Citation associated with the agent response
generatedResponsePart (dict) --
Generate response part
textResponsePart (dict) --
Text response part
text (string) --
Response part in text
span (dict) --
Span of text
start (integer) --
Start of span
end (integer) --
End of span
retrievedReferences (list) --
list of retrieved references
(dict) --
Retrieved reference
content (dict) --
Content of a retrieval result.
text (string) --
Content of a retrieval result in text
location (dict) --
The source location of a retrieval result.
type (string) --
The location type of a retrieval result.
s3Location (dict) --
The S3 location of a retrieval result.
uri (string) --
URI of S3 location