retrieve_and_generate
async
¶
retrieve_and_generate(
input: RetrieveAndGenerateInput,
*,
config_overrides: Optional[AsyncBedrockAgentRuntimeClientConfig] = None,
session_id: Optional[SessionId] = None,
retrieve_and_generate_configuration: Optional[
RetrieveAndGenerateConfiguration
] = None,
session_configuration: Optional[RetrieveAndGenerateSessionConfiguration] = None,
user_context: Optional[UserContext] = None,
) -> RetrieveAndGenerateResponse
Queries a knowledge base and generates responses based on the retrieved results and using the specified foundation model or inference profile. The response only cites sources that are relevant to the query.
This API cannot be used with managed knowledge bases. Use AgenticRetrieveStream or Retrieve with managed knowledge bases.
Parameters:
-
session_id(Optional[SessionId], default:None) –The unique identifier of the session. When you first make a
RetrieveAndGeneraterequest, 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 thesessionIdyourself. -
input(RetrieveAndGenerateInput) –Contains the query to be made to the knowledge base.
-
retrieve_and_generate_configuration(Optional[RetrieveAndGenerateConfiguration], default:None) –Contains configurations for the knowledge base query and retrieval process. For more information, see Query configurations.
-
session_configuration(Optional[RetrieveAndGenerateSessionConfiguration], default:None) –Contains details about the session with the knowledge base.
-
user_context(Optional[UserContext], default:None) –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.
Raises:
-
AccessDeniedException–The request is denied because of missing access permissions. Check your permissions and retry your request.
-
BadGatewayException–There was an issue with a dependency due to a server issue. Retry your request.
-
ConflictException–There was a conflict performing an operation. Resolve the conflict and retry your request.
-
DependencyFailedException–There was an issue with a dependency. Check the resource configurations and retry the request.
-
InternalServerException–An internal server error occurred. Retry your request.
-
ResourceNotFoundException–The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and try your request again.
-
ServiceQuotaExceededException–The number of requests exceeds the service quota. Resubmit your request later.
-
ThrottlingException–The number of requests exceeds the limit. Resubmit your request later.
-
ValidationException–Input validation failed. Check your request parameters and retry the request.
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_bedrock_agent_runtime/_services/async_bedrock_agent_runtime.py
2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 | |