mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-11 23:47:11 +00:00
Merge pull request #1943 from deenaawny-github-account/main
support langfuse tags feature
This commit is contained in:
@@ -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`
|
||||
|
||||
@@ -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
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -230,6 +230,10 @@ class LangFuseLogger:
|
||||
|
||||
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
|
||||
@@ -274,8 +278,7 @@ class LangFuseLogger:
|
||||
"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),
|
||||
|
||||
Generated
+743
-627
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -7,7 +7,7 @@ license = "MIT"
|
||||
readme = "README.md"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.8.1,<3.9.7 || >3.9.7"
|
||||
python = ">=3.8.1,<4.0, !=3.9.7"
|
||||
openai = ">=1.0.0"
|
||||
python-dotenv = ">=0.2.0"
|
||||
tiktoken = ">=0.4.0"
|
||||
|
||||
Reference in New Issue
Block a user