Create examples in a dataset.
create_examples(
self,
*,
dataset_name: Optional[str] = None,
dataset_id: Optional[ID_TYPE] = None,
examples: Optional[Sequence[ls_schemas.ExampleCreate | dict]] = None,
dangerously_allow_filesystem: bool = False,
max_concurrency: Annotated[int, Field(ge=1, le=3)] = 1,
**kwargs: Any = {}
) -> ls_schemas.UpsertExamplesResponse | dict[str, Any]Updated to take argument 'examples', a single list where each element is the full example to create. This should be used instead of the legacy 'inputs', 'outputs', etc. arguments which split each examples attributes across arguments.
Updated to support creating examples with attachments.
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": [...| Name | Type | Description |
|---|---|---|
dataset_name | str | None | Default: NoneThe name of the dataset to create the examples in. Must specify exactly one of dataset_name or dataset_id. |
dataset_id | UUID | str | None | Default: NoneThe ID of the dataset to create the examples in. Must specify exactly one of dataset_name or dataset_id |
examples | Sequence[ExampleCreate | dict] | Default: NoneThe examples to create. |
dangerously_allow_filesystem | bool | Default: FalseWhether to allow uploading files from the filesystem. |
**kwargs | Any | Default: {}Legacy keyword args. Should not be specified if 'examples' is specified.
|