forked from phoenix/litellm-mirror
(docs) langfuse log trace id, trace user id
This commit is contained in:
parent
84fbc903aa
commit
c269c65371
1 changed files with 37 additions and 0 deletions
|
@ -57,6 +57,8 @@ response = litellm.completion(
|
|||
## Advanced
|
||||
### Set Custom Generation names, pass metadata
|
||||
|
||||
Pass `generation_name` in `metadata`
|
||||
|
||||
```python
|
||||
import litellm
|
||||
from litellm import completion
|
||||
|
@ -91,6 +93,41 @@ print(response)
|
|||
|
||||
```
|
||||
|
||||
### Set Custom Trace ID, Trace User ID
|
||||
|
||||
Pass `trace_id`, `trace_user_id` in `metadata`
|
||||
|
||||
```python
|
||||
import litellm
|
||||
from litellm import completion
|
||||
import os
|
||||
|
||||
# from https://cloud.langfuse.com/
|
||||
os.environ["LANGFUSE_PUBLIC_KEY"] = ""
|
||||
os.environ["LANGFUSE_SECRET_KEY"] = ""
|
||||
|
||||
os.environ['OPENAI_API_KEY']=""
|
||||
|
||||
# set langfuse as a callback, litellm will send the data to langfuse
|
||||
litellm.success_callback = ["langfuse"]
|
||||
|
||||
# set custom langfuse trace params and generation params
|
||||
response = completion(
|
||||
model="gpt-3.5-turbo",
|
||||
messages=[
|
||||
{"role": "user", "content": "Hi 👋 - i'm openai"}
|
||||
],
|
||||
metadata={
|
||||
"generation_name": "ishaan-test-generation", # set langfuse Generation Name
|
||||
"generation_id": "gen-id22", # set langfuse Generation ID
|
||||
"trace_id": "trace-id22", # set langfuse Trace ID
|
||||
"trace_user_id": "user-id2", # set langfuse Trace User ID
|
||||
},
|
||||
)
|
||||
|
||||
print(response)
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Troubleshooting & Errors
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue