sample
async
¶
sample(
job_arn: JobArn,
trajectory_id: TrajectoryId,
body: InferenceRequestBody,
*,
config_overrides: Optional[AsyncSagemakerJobRuntimeClientConfig] = None,
) -> SampleResponse
Sends an inference request to the model during a job execution. The request and response bodies are forwarded to and from the model without modification. Each turn (prompt and response) is captured for later use.
Parameters:
-
job_arn(JobArn) –The job ARN that identifies which model session to route the inference request to.
-
trajectory_id(TrajectoryId) –The trajectory ID for grouping turns into a single rollout. Each turn (prompt and response) is captured for later use.
-
body(InferenceRequestBody) –The raw inference request body in OpenAI-compatible JSON format.
Raises:
-
AccessDeniedException–You do not have permission to perform this operation.
-
InternalServiceError–An internal service error occurred. Retry the request.
-
ResourceNotFoundException–The specified resource was not found.
-
ServiceQuotaExceededException–You have exceeded a service quota.
-
ThrottlingException–The request was throttled. Retry the request after a brief wait.
-
ValidationException–The request is not valid. Check the request syntax and parameters
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
Invoke Sample Sends an inference request to the model and receives the response.
>>> await client.sample(job_arn='arn:aws:sagemaker:us-east-1:123456789012:job/AgentRFT/my-training-job', trajectory_id='trajectory-001', body='eyJtb2RlbCI6Im15LW1vZGVsIiwibWVzc2FnZXMiOlt7InJvbGUiOiJ1c2VyIiwiY29udGVudCI6IkhlbGxvIn1dfQ==')
Source code in docs_src/capo_sagemakerjobruntime/_services/async_sagemaker_job_runtime.py
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | |