Replies: 1 comment
-
Hello @reinoldus! I'm here to help you with any bugs, questions, or contributions you have. Let's tackle this issue together! To set the session ID when using OpenLIT, you can use the OpenTelemetry SDKs to export traces directly and include the session ID in the metadata of your trace. For manual tracing, you can set the session ID like this: with openlit.start_trace("Your Trace Name") as trace:
trace.set_metadata({"langfuse.session.id": your_session_id}) For automatic session management, you can use environment variables or configurations to separate user sessions. The OpenLIT documentation suggests using custom resource attributes for this purpose. Unfortunately, I couldn't find specific details on how to implement this using environment variables or custom resource attributes in the available documentation. If you want to avoid manually tracing everything, consider using the from langfuse.decorators import langfuse_context, observe
from langfuse.openai import openai
@observe()
def fn():
langfuse_context.update_current_trace(
session_id="your-session-id"
)
completion = openai.chat.completions.create(
name="test-chat",
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a calculator."},
{"role": "user", "content": "1 + 1 = "}],
temperature=0,
)
fn() This approach allows you to set the session ID dynamically and manage user sessions efficiently [1]. To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other |
Beta Was this translation helpful? Give feedback.
-
Hi,
I am using a crewAi flow with some "raw" llm requests, all the traces are correctly send to langfuse, but I can't figure out how to set the sessionid mentioned here: https://langfuse.com/docs/opentelemetry/get-started
How can I access the trace and set the id?
If I use manual tracing like this then it works, but then I would have to manually trace everything:
The openlit docs mention something around setting env_vars_ https://docs.openlit.io/latest/features/tracing#add-custom-resource-attributes
But now sure how I should separate different user sessions like that.
Beta Was this translation helpful? Give feedback.
All reactions