-
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: 3 comments 2 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.
I figured it out by customizing
run_id
of 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.