Update the state of a thread.
update_state(
self,
thread_id: str,
values: dict[str, Any] | Sequence[dict] | None,
*,
as_node: str | None = None,
checkpoint: Checkpoint | None = None,
checkpoint_id: str | None = None,
headers: Mapping[str, str] | None = None,
params: QueryParamTypes | None = None
) -> ThreadUpdateStateResponse
response = await client.threads.update_state(
thread_id="my_thread_id",
values={"messages":[{"role": "user", "content": "hello!"}]},
as_node="my_node",
)
print(response)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
{
'checkpoint': {
'thread_id': 'e2496803-ecd5-4e0c-a779-3226296181c2',
'checkpoint_ns': '',
'checkpoint_id': '1ef4a9b8-e6fb-67b1-8001-abd5184439d1',
'checkpoint_map': {}
}
}| Name | Type | Description |
|---|---|---|
thread_id* | str | The ID of the thread to update. |
values* | dict[str, Any] | Sequence[dict] | None | The values to update the state with. |
as_node | str | None | Default: NoneUpdate the state as if this node had just executed. |
checkpoint | Checkpoint | None | Default: NoneThe checkpoint to update the state of. |
headers | Mapping[str, str] | None | Default: NoneOptional custom headers to include with the request. |