I want to know how to use my knowledge base session more than once in Amazon Bedrock.
Resolution
Note: A knowledge base session lasts for only 24 hours, and you can't extend the session.
To reuse a knowledge base session after the 24 hours, get a session ID for the knowledge base session. Then, specify the session ID in the next API call input.
Complete the following steps:
-
Use the request syntax to call the RetrieveAndGenerate API that assigns the session ID to the current knowledge base session.
-
Get the sessionId from the API call's response syntax.
Example output:
{
"citations": [
{
"generatedResponsePart": {
"textResponsePart": {
"span": {
"end": number,
"start": number
},
"text": "string"
}
},
"retrievedReferences": [
{
"content": {
"text": "string"
},
"location": {
"s3Location": {
"uri": "string"
},
"type": "string"
},
"metadata": {
"string" : JSON value
}
}
]
}
],
"output": {
"text": "string"
},
"sessionId": "string"
}
-
Specify the session ID in the next API call input within 24 hours to continue to use the same session.
Note: The knowledge base remembers your previous conversation and provides the answers.
If you don't want to reuse a knowledge base session, then remove the session ID from the API call input to automatically create a new session.