Skip to content

Commit

Permalink
Merge branch 'isaac/multipartstuff' into isaac/addattachmentsevaluator
Browse files Browse the repository at this point in the history
  • Loading branch information
isahers1 authored Dec 9, 2024
2 parents 799f69c + 1abe4f9 commit ac16178
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion python/langsmith/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3477,6 +3477,13 @@ def _prepate_multipart_data(
dataset_id = examples[0].dataset_id

for example in examples:
if not isinstance(
example, ls_schemas.ExampleUploadWithAttachments
) and not isinstance(example, ls_schemas.ExampleUpsertWithAttachments):
raise ValueError(
"The examples must be of type ExampleUploadWithAttachments"
" or ExampleUpsertWithAttachments"
)
if example.id is not None:
example_id = str(example.id)
else:
Expand Down Expand Up @@ -3591,7 +3598,7 @@ def upload_examples_multipart(
) -> ls_schemas.UpsertExamplesResponse:
"""Upload examples."""
if not (self.info.instance_flags or {}).get(
"examples_multipart_enabled", False
"dataset_examples_multipart_enabled", False
):
raise ValueError(
"Your LangSmith version does not allow using the multipart examples endpoint, please update to the latest version."
Expand Down
2 changes: 1 addition & 1 deletion python/tests/integration_tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ def test_upsert_examples_multipart(langchain_client: Client) -> None:
assert len(all_examples_in_dataset) == 2

# Throw type errors when not passing ExampleUpsertWithAttachments
with pytest.raises(AttributeError):
with pytest.raises(ValueError):
langchain_client.upsert_examples_multipart(upserts=[{"foo": "bar"}])
langchain_client.delete_dataset(dataset_name=dataset_name)

Expand Down

0 comments on commit ac16178

Please sign in to comment.