Updates the reward values for a trajectory and transitions it to reward-received status, signaling that it is eligible for processing. Call this operation after CompleteRollout to provide the computed reward scores.
Parameters:
-
job_arn
(JobArn)
–
-
trajectory_id
(TrajectoryId)
–
The trajectory ID to update with reward values.
-
rewards
(DoubleList)
–
The list of reward values to assign to this trajectory. Provide one reward value per turn in the trajectory.
-
client_token
(Optional[str], default:
None
)
–
A unique, case-sensitive identifier that you provide to ensure the idempotency of the request.
Raises:
Examples:
Invoke UpdateReward
Updates the reward values for a completed trajectory.
>>> client.update_reward(job_arn='arn:aws:sagemaker:us-east-1:123456789012:job/AgentRFT/my-training-job', trajectory_id='trajectory-001', rewards=[0.85, 0.92, 0.78])
Source code in docs_src/capo_sagemakerjobruntime/_services/sagemaker_job_runtime.py
| def update_reward(
self,
job_arn: "capo_sagemakerjobruntime.types.job_arn.JobArn",
trajectory_id: "capo_sagemakerjobruntime.types.trajectory_id.TrajectoryId",
rewards: "capo_sagemakerjobruntime.types.double_list.DoubleList",
*,
config_overrides: Optional[SagemakerJobRuntimeClientConfig] = None,
client_token: Optional[str] = None,
) -> "capo_sagemakerjobruntime.types.update_reward_response.UpdateRewardResponse":
"""Updates the reward values for a trajectory and transitions it to reward-received status, signaling that it is eligible for processing. Call this operation after CompleteRollout to provide the computed reward scores.
Args:
job_arn: The job ARN.
trajectory_id: The trajectory ID to update with reward values.
rewards: The list of reward values to assign to this trajectory. Provide one reward value per turn in the trajectory.
client_token: A unique, case-sensitive identifier that you provide to ensure the idempotency of the request.
Raises:
capo_sagemakerjobruntime.errors.access_denied_exception.AccessDeniedException: You do not have permission to perform this operation.
capo_sagemakerjobruntime.errors.conflict_exception.ConflictException: The request conflicts with the current state of the resource.
capo_sagemakerjobruntime.errors.internal_service_error.InternalServiceError: An internal service error occurred. Retry the request.
capo_sagemakerjobruntime.errors.resource_not_found_exception.ResourceNotFoundException: The specified resource was not found.
capo_sagemakerjobruntime.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: You have exceeded a service quota.
capo_sagemakerjobruntime.errors.throttling_exception.ThrottlingException: The request was throttled. Retry the request after a brief wait.
capo_sagemakerjobruntime.errors.validation_exception.ValidationException: The request is not valid. Check the request syntax and parameters
capo_sagemakerjobruntime.errors.UnknownServiceError: The service returned an error code this client does not model.
Examples:
Invoke UpdateReward
Updates the reward values for a completed trajectory.
>>> client.update_reward(job_arn='arn:aws:sagemaker:us-east-1:123456789012:job/AgentRFT/my-training-job', trajectory_id='trajectory-001', rewards=[0.85, 0.92, 0.78])
"""
def _handler(
req: "OperationRequest[capo_sagemakerjobruntime.types.update_reward_request.UpdateRewardRequest]",
) -> OperationResponse[
"capo_sagemakerjobruntime.types.update_reward_response.UpdateRewardResponse"
]:
import capo_sagemakerjobruntime._operations.agentic_rft_runtime_service.update_reward
output, http_response = (
capo_sagemakerjobruntime._operations.agentic_rft_runtime_service.update_reward.update_reward(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("UpdateReward")
)
input_: capo_sagemakerjobruntime.types.update_reward_request.UpdateRewardRequest = {
"job_arn": job_arn,
"trajectory_id": trajectory_id,
"rewards": rewards,
}
if client_token is None:
client_token = str(uuid.uuid4())
input_["client_token"] = client_token
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|