-
|
When following the Customize IDs section, it supports changing trace id for a function decorated with How to do the same thing without the decorator? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 8 replies
-
|
Hey there, @shawnzhu! I'm here to help you with any bugs, questions, or contributions you have while waiting for a human maintainer. Let's dive in and solve this together! To customize the trace ID when using a callback handler in Langchain integration without using the import { CallbackHandler } from "langfuse-langchain/src/callback";
// Create a callback handler with a custom user ID
const langfuseHandler = new CallbackHandler({ userId: "your-user-id", sdkIntegration: "your-sdk-integration" });You can then use this handler in your Langchain invocations: chain.invoke({ person: "obama", language: "spanish" }, { callbacks: [langfuseHandler] });This approach allows you to set a custom trace ID without using the |
Beta Was this translation helpful? Give feedback.
-
|
I figured it out by customizing from langfuse.callback import CallbackHandler
run_id = uuid4()
langfuse_handler = CallbackHandler();
agent.invoke({"input": input}, config={"callbacks":[langfuse_handler], "run_id": run_id})Notice that it will also changed the run_id of this langchain runnable as well. |
Beta Was this translation helpful? Give feedback.
-
|
FWIW, this works too |
Beta Was this translation helpful? Give feedback.
-
|
@marcklingen @jannikmaierhoefer In |
Beta Was this translation helpful? Give feedback.
-
|
In langfuse SDK v3, you can now set the langfuse trace id like this: import uuid
from langfuse.langchain import CallbackHandler
trace_id = str(uuid.uuid4()).replace("-", "")
handler = CallbackHandler(trace_context={"trace_id": trace_id})You can also generate a trace id from any value using |
Beta Was this translation helpful? Give feedback.
I figured it out by customizing
run_idof a Langchain runnable, which is later used as trace id.Notice that it will also changed the run_id of this langchain runnable as well.