From 4258828969e683fbf0404c5d994955cb9daaf8a4 Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Wed, 18 Oct 2023 12:00:12 -0700 Subject: [PATCH] (fix) langsmith logger track project_name and run_name --- litellm/integrations/langsmith.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/litellm/integrations/langsmith.py b/litellm/integrations/langsmith.py index 9018a0b29a..43e9de4d34 100644 --- a/litellm/integrations/langsmith.py +++ b/litellm/integrations/langsmith.py @@ -17,13 +17,16 @@ class LangsmithLogger: def log_event(self, kwargs, response_obj, start_time, end_time, print_verbose): # Method definition # inspired by Langsmith http api here: https://github.com/langchain-ai/langsmith-cookbook/blob/main/tracing-examples/rest/rest.ipynb - metadata = kwargs.get("metadata", {}) + metadata = {} + if "litellm_params" in kwargs: + metadata = kwargs["litellm_params"].get("metadata", {}) # 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") + print_verbose(f"Langsmith Logging - project_name: {project_name}, run_name {run_name}") try: print_verbose( f"Langsmith Logging - Enters logging function for model {kwargs}"