Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
hinthornw committed Mar 13, 2024
1 parent ef034b2 commit 71e427e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 8 additions & 4 deletions python/langsmith/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,14 @@ def _get_tracing_sampling_rate() -> float | None:


def _get_api_key(api_key: Optional[str]) -> Optional[str]:
api_key = api_key or os.getenv("LANGSMITH_API_KEY", os.getenv("LANGCHAIN_API_KEY"))
if api_key is None or not api_key.strip():
api_key_ = (
api_key
if api_key is not None
else os.getenv("LANGSMITH_API_KEY", os.getenv("LANGCHAIN_API_KEY"))
)
if api_key_ is None or not api_key_.strip():
return None
return api_key.strip().strip('"').strip("'")
return api_key_.strip().strip('"').strip("'")


def _get_api_url(api_url: Optional[str]) -> str:
Expand Down Expand Up @@ -452,7 +456,7 @@ def __init__(
) and os.getenv("LANGSMITH_RUNS_ENDPOINTS"):
raise ls_utils.LangSmithUserError(
"You cannot provide both LANGSMITH_ENDPOINT / LANGCHAIN_ENDPOINT "
"and LANGSMITH_ENDPOINTS."
"and LANGSMITH_RUNS_ENDPOINTS."
)

self.tracing_sample_rate = _get_tracing_sampling_rate()
Expand Down
2 changes: 2 additions & 0 deletions python/tests/unit_tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ def test_validate_multiple_urls(monkeypatch: pytest.MonkeyPatch) -> None:
"https://api.smith.langsmith-endpoint_2.com": "456",
"https://api.smith.langsmith-endpoint_3.com": "789",
}
monkeypatch.delenv("LANGCHAIN_ENDPOINT")
monkeypatch.delenv("LANGSMITH_ENDPOINT", raising=False)
monkeypatch.setenv("LANGSMITH_RUNS_ENDPOINTS", json.dumps(data))
client = Client()
assert client._write_api_urls == data
Expand Down

0 comments on commit 71e427e

Please sign in to comment.