LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • Client
  • AsyncClient
  • Run Helpers
  • Run Trees
  • Evaluation
  • Schemas
  • Utilities
  • Wrappers
  • Anonymizer
  • Testing
  • Expect API
  • Middleware
  • Pytest Plugin
  • Deployment SDK
⌘I

Chat LangChain

What can I help with?

Enter to send·Shift+Enter new line

Menu

OverviewClientAsyncClientRun HelpersRun TreesEvaluationSchemasUtilitiesWrappersAnonymizerTestingExpect APIMiddlewarePytest PluginDeployment SDK
Language
Theme
PythonlangsmithclientClientcreate_examples
Method●Since v0.5

create_examples

Copy
create_examples(
  self,
  *,
  dataset_name: Optional[str] = None,
  dataset_id: Optional
View source on GitHub
[
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
]

Parameters

NameTypeDescription
dataset_namestr | None
Default:None

The name of the dataset to create the examples in. Must specify exactly one of dataset_name or dataset_id.

dataset_idUUID | str | None
Default:None

The ID of the dataset to create the examples in. Must specify exactly one of dataset_name or dataset_id

examplesSequence[ExampleCreate | dict]
Default:None
dangerously_allow_filesystembool
Default:False
**kwargsAny
Default:{}

Create examples in a dataset.

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', 'reference_outputs', etc. arguments which split each example's 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"},
        "reference_outputs": {"answer": "an agent is..."},
        "metadata": {"difficulty": "easy"},
    },
    {
        "inputs": {"question": "can you explain the agent architecture in this diagram?"},
        "reference_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": [...

The examples to create.

Whether to allow uploading files from the filesystem.

Legacy keyword args. Should not be specified if 'examples' is specified.

  • inputs (Sequence[Mapping[str, Any]]): The input values for the examples.
  • reference_outputs (Optional[Sequence[Optional[Mapping[str, Any]]]]): The reference output values for the examples.
  • outputs (Optional[Sequence[Optional[Mapping[str, Any]]]]): Deprecated alias for reference_outputs.
  • metadata (Optional[Sequence[Optional[Mapping[str, Any]]]]): The metadata for the examples.
  • splits (Optional[Sequence[Optional[str | List[str]]]]): The splits for the examples, which are divisions of your dataset such as 'train', 'test', or 'validation'.
  • source_run_ids (Optional[Sequence[Optional[Union[UUID, str]]]]): The IDs of the source runs associated with the examples.
  • ids (Optional[Sequence[Union[UUID, str]]]): The IDs of the examples.