In langchain-js versions after v1.0, parameters can no longer be passed to the CallbackHandler constructor. Instead, they should be passed within the invoke method.
Here is the correct approach:
// ...
const langfuseHandler = new CallbackHandler({});
// ...
console.log(
await agent.invoke(
{
messages: [
{ role: "user", content: "What's the weather in San Francisco?" },
],
},
{
callbacks: [langfuseHandler],
metadata: {
langfuse_session_id: "user-session-123",
langfuse_user_id: "user-abc",
langfuse_tags: ["langchain-test"],
},
}
)
);
I think we should highlight the differences in usage between versions before and after v1.0.
In langchain-js versions after v1.0, parameters can no longer be passed to the
CallbackHandlerconstructor. Instead, they should be passed within theinvokemethod.Here is the correct approach:
I think we should highlight the differences in usage between versions before and after v1.0.