Skip to content

Commit 242981c

Browse files
committed
Deactivate LangSmith
1 parent 146f987 commit 242981c

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

libs/e2e-tests/e2e_tests/test_utils/tracing.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
import logging
2+
import os
23
import time
34
from typing import Callable
45

56
from langsmith import Client
67

7-
LANGSMITH_CLIENT = Client()
8+
if (
9+
os.getenv("LANGSMITH_API_KEY", "").strip()
10+
or os.getenv("LANGCHAIN_API_KEY", "").strip()
11+
):
12+
LANGSMITH_CLIENT = Client()
13+
else:
14+
LANGSMITH_CLIENT = None
815

916

1017
def record_langsmith_sharelink(
1118
run_id: str, record_property: Callable, tries: int = 6
1219
) -> None:
1320
try:
14-
sharelink = LANGSMITH_CLIENT.share_run(run_id)
21+
sharelink = (
22+
LANGSMITH_CLIENT.share_run(run_id) if LANGSMITH_CLIENT else "deactivated"
23+
)
1524
record_property("langsmith_url", sharelink)
1625
logging.info("recorded langsmith link: %s", sharelink)
1726
except Exception:

0 commit comments

Comments
 (0)