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
  • RemoteGraph
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

OverviewClientAsyncClientRun HelpersRun TreesEvaluationSchemasUtilitiesWrappersAnonymizerTestingExpect APIMiddlewarePytest PluginDeployment SDKRemoteGraph
Language
Theme
PythonlangsmithclientClientupdate_examples
Method●Since v0.1

update_examples

Update multiple examples.

Examples are expected to all be part of the same dataset.

Copy
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": [...

Parameters

NameTypeDescription
dataset_namestr | None
Default:None

The name of the dataset to update. Should specify exactly one of 'dataset_name' or 'dataset_id'.

dataset_idUUID | str | None
Default:None

The ID of the dataset to update. Should specify exactly one of 'dataset_name' or 'dataset_id'.

updatesSequence[ExampleUpdate | dict] | None
Default:None

The example updates. Overwrites any specified fields and does not update any unspecified fields.

dangerously_allow_filesystembool
Default:False

Whether to allow using filesystem paths as attachments.

**kwargsAny
Default:{}

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

  • example_ids (Sequence[UUID | str]): The IDs of the examples to update.
  • inputs (Sequence[dict | None] | None): The input values for the examples.
  • outputs (Sequence[dict | None] | None): The output values for the examples.
  • metadata (Sequence[dict | None] | None): The metadata for the examples.
  • splits (Sequence[str | list[str] | None] | None): The splits for the examples, which are divisions of your dataset such as 'train', 'test', or 'validation'.
  • attachments_operations (Sequence[AttachmentsOperations | None] | None): The operations to perform on the attachments.
  • dataset_ids (Sequence[UUID | str] | None): The IDs of the datasets to move the examples to.
View source on GitHub