diff --git a/litellm/integrations/langsmith.py b/litellm/integrations/langsmith.py index d951d69244a..6f796b58c27 100644 --- a/litellm/integrations/langsmith.py +++ b/litellm/integrations/langsmith.py @@ -13,6 +13,10 @@ class LangsmithLogger: # Class variables or attributes def __init__(self): self.langsmith_api_key = os.getenv("LANGSMITH_API_KEY") + self.langsmith_project = os.getenv("LANGSMITH_PROJECT", "litellm-completion") + self.langsmith_default_run_name = os.getenv( + "LANGSMITH_DEFAULT_RUN_NAME", "LLMRun" + ) def log_event(self, kwargs, response_obj, start_time, end_time, print_verbose): # Method definition @@ -23,9 +27,9 @@ class LangsmithLogger: # set project name and run_name for langsmith logging # users can pass project_name and run name to litellm.completion() # Example: litellm.completion(model, messages, metadata={"project_name": "my-litellm-project", "run_name": "my-langsmith-run"}) - # if not set litellm will use default project_name = litellm-completion, run_name = LLMRun - project_name = metadata.get("project_name", "litellm-completion") - run_name = metadata.get("run_name", "LLMRun") + # if not set litellm will fallback to the environment variable LANGSMITH_PROJECT, then to the default project_name = litellm-completion, run_name = LLMRun + project_name = metadata.get("project_name", self.langsmith_project) + run_name = metadata.get("run_name", self.langsmith_default_run_name) print_verbose( f"Langsmith Logging - project_name: {project_name}, run_name {run_name}" )