Skip to content

Commit

Permalink
0.0.40 (#236)
Browse files Browse the repository at this point in the history
  • Loading branch information
hinthornw authored Sep 21, 2023
1 parent 061706d commit c66383c
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 104 deletions.
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "langsmith",
"version": "0.0.39",
"version": "0.0.40",
"description": "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform.",
"files": [
"dist/",
Expand Down
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.0.39"
version = "0.0.40"
description = "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform."
authors = ["LangChain <support@langchain.dev>"]
license = "MIT"
Expand Down
102 changes: 0 additions & 102 deletions python/tests/integration_tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,108 +125,6 @@ def test_datasets(langchain_client: Client) -> None:
langchain_client.delete_dataset(dataset_id=dataset_id)


@freeze_time("2023-01-01")
def test_run_tree(monkeypatch: pytest.MonkeyPatch, langchain_client: Client) -> None:
"""Test persisting runs and adding feedback."""
monkeypatch.setenv("LANGCHAIN_ENDPOINT", "http://localhost:1984")
project_name = "__test_run_tree"
if project_name in [sess.name for sess in langchain_client.list_projects()]:
langchain_client.delete_project(project_name=project_name)
parent_run = RunTree(
name="parent_run",
run_type="chain",
inputs={"text": "hello world"},
start_time=datetime.now(),
project_name=project_name,
serialized={},
client=langchain_client,
)
child_llm_run = parent_run.create_child(
name="child_run", run_type="llm", inputs={"text": "hello world"}
)
child_chain_run = parent_run.create_child(
name="child_chain_run", run_type="chain", inputs={"text": "hello world"}
)
grandchild_chain_run = child_chain_run.create_child(
name="grandchild_chain_run", run_type="chain", inputs={"text": "hello world"}
)
grandchild_chain_run.end(outputs={"output": ["Hi"]})
child_chain_run.end(error="AN ERROR")
child_tool_run = parent_run.create_child(
name="child_tool_run", run_type="tool", inputs={"text": "hello world"}
)
child_tool_run.end(outputs={"output": ["Hi"]})
child_llm_run.end(outputs={"prompts": ["hello world"]})
parent_run.end(outputs={"output": ["Hi"]})
with pytest.warns(
DeprecationWarning, match="Posting with exclude_child_runs=False is deprecated"
):
parent_run.post(exclude_child_runs=False)
parent_run.wait()

runs = list(langchain_client.list_runs(project_name=project_name))
assert len(runs) == 5
run_map = {run.name: run for run in runs}
assert run_map["parent_run"].execution_order == 1
# The child run and child chain run are executed 'in parallel'
assert run_map["child_run"].execution_order == 2
assert run_map["child_chain_run"].execution_order == 3
assert run_map["grandchild_chain_run"].execution_order == 4
assert run_map["child_tool_run"].execution_order == 5

assert run_map["child_run"].parent_run_id == run_map["parent_run"].id
assert run_map["child_chain_run"].parent_run_id == run_map["parent_run"].id
assert (
run_map["grandchild_chain_run"].parent_run_id == run_map["child_chain_run"].id
)
assert run_map["child_tool_run"].parent_run_id == run_map["parent_run"].id
assert run_map["parent_run"].parent_run_id is None

nested_run = langchain_client.read_run(
run_map["parent_run"].id, load_child_runs=True
)
assert nested_run.child_runs is not None
assert len(nested_run.child_runs) == 3
first_two = {
child_run_.name: child_run_ for child_run_ in nested_run.child_runs[:2]
}
assert set(first_two) == {"child_run", "child_chain_run"}
assert nested_run.child_runs[2].name == "child_tool_run"
assert first_two["child_chain_run"].child_runs is not None
assert len(first_two["child_chain_run"].child_runs) == 1
assert first_two["child_chain_run"].child_runs[0].name == "grandchild_chain_run"

langchain_client.create_feedback(
runs[0].id, # type: ignore
"supermetric",
value={"clarity": "good", "fluency": "good", "relevance": "very bad"},
score=0.5,
)
feedback_2 = langchain_client.create_feedback(runs[0].id, "a tag") # type: ignore
assert feedback_2.value is None
langchain_client.update_feedback(
feedback_2.id, correction={"good_output": "a correction"}
)
feedbacks = list(
langchain_client.list_feedback(run_ids=[runs[0].id]) # type: ignore
)
assert len(feedbacks) == 2
assert feedbacks[0].run_id == runs[0].id
assert langchain_client.read_feedback(feedback_2.id).correction == {
"good_output": "a correction"
}
feedback = langchain_client.read_feedback(feedbacks[0].id)
assert feedback.id == feedbacks[0].id
langchain_client.delete_feedback(feedback.id)
with pytest.raises(LangSmithError):
langchain_client.read_feedback(feedback.id)
assert len(list(langchain_client.list_feedback(run_ids=[runs[0].id]))) == 1
langchain_client.read_project(project_name=project_name)
langchain_client.delete_project(project_name=project_name)
with pytest.raises(LangSmithError):
langchain_client.read_project(project_name=project_name)


@freeze_time("2023-01-01")
def test_persist_update_run(
monkeypatch: pytest.MonkeyPatch, langchain_client: Client
Expand Down

0 comments on commit c66383c

Please sign in to comment.