From b41b835c77d5863d5c5016fc35f3a6570af739e0 Mon Sep 17 00:00:00 2001 From: William FH <13333726+hinthornw@users.noreply.github.com> Date: Wed, 8 Jan 2025 03:14:25 -0800 Subject: [PATCH] Delete examples bulk (#1279) Closes #1272 --- python/langsmith/client.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/python/langsmith/client.py b/python/langsmith/client.py index 5dae4a38c..ab4a562b8 100644 --- a/python/langsmith/client.py +++ b/python/langsmith/client.py @@ -4761,6 +4761,29 @@ def delete_example(self, example_id: ID_TYPE) -> None: ) ls_utils.raise_for_status_with_text(response) + def delete_examples(self, example_ids: Sequence[ID_TYPE]) -> None: + """Delete multiple examples by ID. + + Parameters + ---------- + example_ids : Sequence[ID_TYPE] + The IDs of the examples to delete. + """ + response = self.request_with_retries( + "DELETE", + "/examples", + headers={**self._headers, "Content-Type": "application/json"}, + data=_dumps_json( + { + "ids": [ + str(_as_uuid(id_, f"example_ids[{i}]")) + for i, id_ in enumerate(example_ids) + ] + } + ), + ) + ls_utils.raise_for_status_with_text(response) + def list_dataset_splits( self, *,