Skip to content

Incorrect parameter passing for metadata in the langchain-js framework #2370

@Wyatex

Description

@Wyatex

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.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions