Skip to content

Commit

Permalink
Merge pull request #1943 from deenaawny-github-account/main
Browse files Browse the repository at this point in the history
support langfuse tags feature
  • Loading branch information
ishaan-jaff committed Feb 12, 2024
2 parents 5d59fa1 + 2d62353 commit 418fb09
Show file tree
Hide file tree
Showing 4 changed files with 751 additions and 631 deletions.
3 changes: 2 additions & 1 deletion docs/my-website/docs/observability/langfuse_integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ print(response)

```

### Set Custom Trace ID, Trace User ID
### Set Custom Trace ID, Trace User ID and Tags

Pass `trace_id`, `trace_user_id` in `metadata`

Expand Down Expand Up @@ -124,6 +124,7 @@ response = completion(
"trace_id": "trace-id22", # set langfuse Trace ID
"trace_user_id": "user-id2", # set langfuse Trace User ID
"session_id": "session-1", # set langfuse Session ID
"tags": ["tag1", "tag2"] # set langfuse Tags
},
)

Expand Down
7 changes: 5 additions & 2 deletions litellm/integrations/langfuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ def _log_langfuse_v2(

print_verbose(f"Langfuse Layer Logging - logging to langfuse v2 ")

if supports_tags:
metadata_tags = metadata["tags"]
tags = metadata_tags

generation_name = metadata.get("generation_name", None)
if generation_name is None:
# just log `litellm-{call_type}` as the generation name
Expand Down Expand Up @@ -274,8 +278,7 @@ def _log_langfuse_v2(
"prompt_tokens": response_obj["usage"]["prompt_tokens"],
"completion_tokens": response_obj["usage"]["completion_tokens"],
"total_cost": cost if supports_costs else None,
}

}
generation_params = {
"name": generation_name,
"id": metadata.get("generation_id", generation_id),
Expand Down
Loading

0 comments on commit 418fb09

Please sign in to comment.