Skip to content

Commit

Permalink
[Python] (Beta) Async Client (#925)
Browse files Browse the repository at this point in the history
Co-authored-by: Jake Rachleff <jake@langchain.dev>
  • Loading branch information
hinthornw and jakerachleff authored Aug 20, 2024
1 parent 8a53cf2 commit f66be6f
Show file tree
Hide file tree
Showing 10 changed files with 1,034 additions and 79 deletions.
6 changes: 6 additions & 0 deletions python/langsmith/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
if TYPE_CHECKING:
from langsmith._expect import expect
from langsmith._testing import test, unit
from langsmith.async_client import AsyncClient
from langsmith.client import Client
from langsmith.evaluation import aevaluate, evaluate
from langsmith.evaluation.evaluator import EvaluationResult, RunEvaluator
Expand Down Expand Up @@ -33,6 +34,10 @@ def __getattr__(name: str) -> Any:
from langsmith.client import Client

return Client
elif name == "AsyncClient":
from langsmith.async_client import AsyncClient

return AsyncClient
elif name == "RunTree":
from langsmith.run_trees import RunTree

Expand Down Expand Up @@ -118,4 +123,5 @@ def __getattr__(name: str) -> Any:
"get_tracing_context",
"get_current_run_tree",
"ContextThreadPoolExecutor",
"AsyncClient",
]
9 changes: 6 additions & 3 deletions python/langsmith/_internal/_beta_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ class LangSmithBetaWarning(UserWarning):
"""This is a warning specific to the LangSmithBeta module."""


@functools.lru_cache(maxsize=100)
def _warn_once(message: str) -> None:
warnings.warn(message, LangSmithBetaWarning, stacklevel=2)


def warn_beta(func: Callable) -> Callable:
@functools.wraps(func)
def wrapper(*args, **kwargs):
warnings.warn(
f"Function {func.__name__} is in beta.", LangSmithBetaWarning, stacklevel=2
)
_warn_once(f"Function {func.__name__} is in beta.")
return func(*args, **kwargs)

return wrapper
Loading

0 comments on commit f66be6f

Please sign in to comment.