Skip to content

Commit

Permalink
[Python] Ensure if null (#969)
Browse files Browse the repository at this point in the history
Calling ensure_config() within from_runnable_config adds unnecessary time in most cases; only call if the input is null
  • Loading branch information
hinthornw authored Sep 4, 2024
1 parent 51537c3 commit f8dd11f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions python/langsmith/run_trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,13 @@ def from_runnable_config(
"RunTree.from_runnable_config requires langchain-core to be installed. "
"You can install it with `pip install langchain-core`."
) from e
config_ = ensure_config(
cast(RunnableConfig, config) if isinstance(config, dict) else None
)
if config is None:
config_ = ensure_config(
cast(RunnableConfig, config) if isinstance(config, dict) else None
)
else:
config_ = cast(RunnableConfig, config)

if (
(cb := config_.get("callbacks"))
and isinstance(cb, (CallbackManager, AsyncCallbackManager))
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.1.110"
version = "0.1.111"
description = "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform."
authors = ["LangChain <support@langchain.dev>"]
license = "MIT"
Expand Down

0 comments on commit f8dd11f

Please sign in to comment.