Skip to content

Retrieve And Generate Stream

bedrockagentruntime_retrieve_and_generate_stream R Documentation

Queries a knowledge base and generates responses based on the retrieved results, with output in streaming format

Description

Queries a knowledge base and generates responses based on the retrieved results, with output in streaming format.

The CLI doesn't support streaming operations in Amazon Bedrock, including InvokeModelWithResponseStream.

Usage

bedrockagentruntime_retrieve_and_generate_stream(input,
  retrieveAndGenerateConfiguration, sessionConfiguration, sessionId)

Arguments

input

[required] Contains the query to be made to the knowledge base.

retrieveAndGenerateConfiguration

Contains configurations for the knowledge base query and retrieval process. For more information, see Query configurations.

sessionConfiguration

Contains details about the session with the knowledge base.

sessionId

The unique identifier of the session. When you first make a retrieve_and_generate request, Amazon Bedrock automatically generates this value. You must reuse this value for all subsequent requests in the same conversational session. This value allows Amazon Bedrock to maintain context and knowledge from previous interactions. You can't explicitly set the sessionId yourself.

Value

A list with the following syntax:

list(
  sessionId = "string",
  stream = list(
    accessDeniedException = list(
      message = "string"
    ),
    badGatewayException = list(
      message = "string",
      resourceName = "string"
    ),
    citation = list(
      citation = list(
        generatedResponsePart = list(
          textResponsePart = list(
            span = list(
              end = 123,
              start = 123
            ),
            text = "string"
          )
        ),
        retrievedReferences = list(
          list(
            content = list(
              byteContent = "string",
              row = list(
                list(
                  columnName = "string",
                  columnValue = "string",
                  type = "BLOB"|"BOOLEAN"|"DOUBLE"|"NULL"|"LONG"|"STRING"
                )
              ),
              text = "string",
              type = "TEXT"|"IMAGE"|"ROW"
            ),
            location = list(
              confluenceLocation = list(
                url = "string"
              ),
              customDocumentLocation = list(
                id = "string"
              ),
              kendraDocumentLocation = list(
                uri = "string"
              ),
              s3Location = list(
                uri = "string"
              ),
              salesforceLocation = list(
                url = "string"
              ),
              sharePointLocation = list(
                url = "string"
              ),
              sqlLocation = list(
                query = "string"
              ),
              type = "S3"|"WEB"|"CONFLUENCE"|"SALESFORCE"|"SHAREPOINT"|"CUSTOM"|"KENDRA"|"SQL",
              webLocation = list(
                url = "string"
              )
            ),
            metadata = list(
              list()
            )
          )
        )
      )
    ),
    conflictException = list(
      message = "string"
    ),
    dependencyFailedException = list(
      message = "string",
      resourceName = "string"
    ),
    guardrail = list(
      action = "INTERVENED"|"NONE"
    ),
    internalServerException = list(
      message = "string"
    ),
    output = list(
      text = "string"
    ),
    resourceNotFoundException = list(
      message = "string"
    ),
    serviceQuotaExceededException = list(
      message = "string"
    ),
    throttlingException = list(
      message = "string"
    ),
    validationException = list(
      message = "string"
    )
  )
)

Request syntax

svc$retrieve_and_generate_stream(
  input = list(
    text = "string"
  ),
  retrieveAndGenerateConfiguration = list(
    externalSourcesConfiguration = list(
      generationConfiguration = list(
        additionalModelRequestFields = list(
          list()
        ),
        guardrailConfiguration = list(
          guardrailId = "string",
          guardrailVersion = "string"
        ),
        inferenceConfig = list(
          textInferenceConfig = list(
            maxTokens = 123,
            stopSequences = list(
              "string"
            ),
            temperature = 123.0,
            topP = 123.0
          )
        ),
        performanceConfig = list(
          latency = "standard"|"optimized"
        ),
        promptTemplate = list(
          textPromptTemplate = "string"
        )
      ),
      modelArn = "string",
      sources = list(
        list(
          byteContent = list(
            contentType = "string",
            data = raw,
            identifier = "string"
          ),
          s3Location = list(
            uri = "string"
          ),
          sourceType = "S3"|"BYTE_CONTENT"
        )
      )
    ),
    knowledgeBaseConfiguration = list(
      generationConfiguration = list(
        additionalModelRequestFields = list(
          list()
        ),
        guardrailConfiguration = list(
          guardrailId = "string",
          guardrailVersion = "string"
        ),
        inferenceConfig = list(
          textInferenceConfig = list(
            maxTokens = 123,
            stopSequences = list(
              "string"
            ),
            temperature = 123.0,
            topP = 123.0
          )
        ),
        performanceConfig = list(
          latency = "standard"|"optimized"
        ),
        promptTemplate = list(
          textPromptTemplate = "string"
        )
      ),
      knowledgeBaseId = "string",
      modelArn = "string",
      orchestrationConfiguration = list(
        additionalModelRequestFields = list(
          list()
        ),
        inferenceConfig = list(
          textInferenceConfig = list(
            maxTokens = 123,
            stopSequences = list(
              "string"
            ),
            temperature = 123.0,
            topP = 123.0
          )
        ),
        performanceConfig = list(
          latency = "standard"|"optimized"
        ),
        promptTemplate = list(
          textPromptTemplate = "string"
        ),
        queryTransformationConfiguration = list(
          type = "QUERY_DECOMPOSITION"
        )
      ),
      retrievalConfiguration = list(
        vectorSearchConfiguration = 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()
            )
          ),
          implicitFilterConfiguration = list(
            metadataAttributes = list(
              list(
                description = "string",
                key = "string",
                type = "STRING"|"NUMBER"|"BOOLEAN"|"STRING_LIST"
              )
            ),
            modelArn = "string"
          ),
          numberOfResults = 123,
          overrideSearchType = "HYBRID"|"SEMANTIC",
          rerankingConfiguration = list(
            bedrockRerankingConfiguration = list(
              metadataConfiguration = list(
                selectionMode = "SELECTIVE"|"ALL",
                selectiveModeConfiguration = list(
                  fieldsToExclude = list(
                    list(
                      fieldName = "string"
                    )
                  ),
                  fieldsToInclude = list(
                    list(
                      fieldName = "string"
                    )
                  )
                )
              ),
              modelConfiguration = list(
                additionalModelRequestFields = list(
                  list()
                ),
                modelArn = "string"
              ),
              numberOfRerankedResults = 123
            ),
            type = "BEDROCK_RERANKING_MODEL"
          )
        )
      )
    ),
    type = "KNOWLEDGE_BASE"|"EXTERNAL_SOURCES"
  ),
  sessionConfiguration = list(
    kmsKeyArn = "string"
  ),
  sessionId = "string"
)