Users
You can track user interactions with your LLM app by setting the user_id
in a trace. This allows you to track things such as how much tokens each user is costing you, who interacted with your LLM app the most, etc.
Set Users At Runtime
You can use the update_current_trace
function to set the user_id
within traces:
Python
from deepeval.tracing import observe, update_current_trace
import openai
@observe()
def llm_app(query: str):
res = openai.ChatCompletion.create(
model="gpt-4o",
messages=[
{"role": "user", "content": query}
]
).choices[0].message["content"]
update_current_trace(user_id="your-user-id")
return res
llm_app("Write me a poem.")
The user_id
can be any string, including the actual IDs of customers in your own database, or even their email addresses. Everything will be viewable and searched in the UI.
Last updated on