Update multiple examples.
Examples are expected to all be part of the same dataset.
update_examples(
self,
*,
dataset_name: str | None = None,
dataset_id: ID_TYPE | None = None,
updates: Optional[Sequence[ls_schemas.ExampleUpdate | dict]] = None,
dangerously_allow_filesystem: bool = False,
**kwargs: Any = {}
) -> dict[str, Any]Updated to ...
Example:
from langsmith import Client
client = Client()
dataset = client.create_dataset("agent-qa")
examples = [
{
"inputs": {"question": "what's an agent"},
"outputs": {"answer": "an agent is..."},
"metadata": {"difficulty": "easy"},
},
{
"inputs": {
"question": "can you explain the agent architecture in this diagram?"
},
"outputs": {"answer": "this diagram shows..."},
"attachments": {"diagram": {"mime_type": "image/png", "data": b"..."}},
"metadata": {"difficulty": "medium"},
},
# more examples...
]
response = client.create_examples(dataset_name="agent-qa", examples=examples)
example_ids = response["example_ids"]
updates = [
{
"id": example_ids[0],
"inputs": {"question": "what isn't an agent"},
"outputs": {"answer": "an agent is not..."},
},
{
"id": example_ids[1],
"attachments_operations": [
{"rename": {"diagram": "agent_diagram"}, "retain": []}
],
},
]
response = client.update_examples(dataset_name="agent-qa", updates=updates)
# -> {"example_ids": [...| Name | Type | Description |
|---|---|---|
dataset_name | str | None | Default: NoneThe name of the dataset to update. Should specify exactly one of 'dataset_name' or 'dataset_id'. |
dataset_id | UUID | str | None | Default: NoneThe ID of the dataset to update. Should specify exactly one of 'dataset_name' or 'dataset_id'. |
updates | Sequence[ExampleUpdate | dict] | None | Default: NoneThe example updates. Overwrites any specified fields and does not update any unspecified fields. |
dangerously_allow_filesystem | bool | Default: FalseWhether to allow using filesystem paths as attachments. |
**kwargs | Any | Default: {}Legacy keyword args. Should not be specified if 'updates' is specified.
|