Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: langchain-ai/langsmith-sdk
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.3.21
Choose a base ref
...
head repository: langchain-ai/langsmith-sdk
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.3.22
Choose a head ref
  • 1 commit
  • 5 files changed
  • 1 contributor

Commits on Apr 1, 2025

  1. fix(py): Always upload multipart inputs and outputs parts even if fal…

    …sey (#1623)
    jacoblee93 authored Apr 1, 2025
    Copy the full SHA
    e8a8dad View commit details
Showing with 39 additions and 24 deletions.
  1. +6 −0 js/src/tests/client.int.test.ts
  2. +20 −22 python/langsmith/client.py
  3. +2 −1 python/langsmith/testing/_internal.py
  4. +1 −1 python/pyproject.toml
  5. +10 −0 python/tests/integration_tests/test_client.py
6 changes: 6 additions & 0 deletions js/src/tests/client.int.test.ts
Original file line number Diff line number Diff line change
@@ -171,6 +171,12 @@ test.concurrent("Test LangSmith Client Dataset CRD", async () => {
client.listExamples({ datasetId: newDataset.id })
);
expect(examples2.length).toBe(2);
await client.createExample({ dataset_id: newDataset.id, inputs: {} });

const examples3 = await toArray(
client.listExamples({ datasetId: newDataset.id })
);
expect(examples3.length).toBe(3);

await client.deleteDataset({ datasetId });
const rawDataset = await client.createDataset(fileName, {
42 changes: 20 additions & 22 deletions python/langsmith/client.py
Original file line number Diff line number Diff line change
@@ -4085,34 +4085,32 @@ def _prepare_multipart_data(
)
)

if example.inputs:
inputsb = _dumps_json(example.inputs)
inputsb = _dumps_json(example.inputs or {})

parts.append(
parts.append(
(
f"{example_id}.inputs",
(
f"{example_id}.inputs",
(
None,
inputsb,
"application/json",
{},
),
)
None,
inputsb,
"application/json",
{},
),
)
)

if example.outputs:
outputsb = _dumps_json(example.outputs)
parts.append(
outputsb = _dumps_json(example.outputs or {})
parts.append(
(
f"{example_id}.outputs",
(
f"{example_id}.outputs",
(
None,
outputsb,
"application/json",
{},
),
)
None,
outputsb,
"application/json",
{},
),
)
)

if example.attachments:
for name, attachment in example.attachments.items():
3 changes: 2 additions & 1 deletion python/langsmith/testing/_internal.py
Original file line number Diff line number Diff line change
@@ -572,6 +572,7 @@ def sync_example(
pytest_plugin=None,
pytest_nodeid=None,
) -> None:
inputs = inputs or {}
if pytest_plugin and pytest_nodeid:
update = {"inputs": inputs, "reference_outputs": outputs}
update = {k: v for k, v in update.items() if v is not None}
@@ -592,7 +593,7 @@ def sync_example(
)
else:
if (
(inputs is not None and inputs != example.inputs)
(inputs != example.inputs)
or (outputs is not None and outputs != example.outputs)
or (metadata is not None and metadata != example.metadata)
or str(example.dataset_id) != str(self.id)
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langsmith"
version = "0.3.21"
version = "0.3.22"
description = "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform."
authors = ["LangChain <support@langchain.dev>"]
license = "MIT"
10 changes: 10 additions & 0 deletions python/tests/integration_tests/test_client.py
Original file line number Diff line number Diff line change
@@ -177,6 +177,16 @@ def test_datasets(langchain_client: Client) -> None:
langchain_client.list_examples(dataset_id=new_dataset.id) # type: ignore
)
assert len(examples2) == 2
langchain_client.create_example(
inputs={},
outputs=None,
dataset_id=new_dataset.id,
)
examples3 = list(
langchain_client.list_examples(dataset_id=new_dataset.id) # type: ignore
)
assert len(examples3) == 3
assert any(example.inputs == {} and example.outputs == {} for example in examples3)
langchain_client.delete_dataset(dataset_id=dataset_id)