langchain-ai / langchainjs

🦜🔗 Build context-aware reasoning applications 🦜🔗
https://js.langchain.com/docs/
MIT License
12.51k stars 2.13k forks source link

Unable to import callbacks from `@langchain/core/callbacks` #6971

Closed tbhaxor closed 1 week ago

tbhaxor commented 1 week ago

Checked other resources

Example Code

import {
  CallbackManagerForRetrieverRun,
  Callbacks,
} from "@langchain/core/callbacks";

Also I have tried in the node REPL

await import("@langchain/core/callbacks")
Uncaught:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './callbacks' is not defined by "exports" in /mnt/Projects/project/server/node_modules/@langchain/core/package.json imported from /mnt/Projects/project/server/repl

Error Message and Stack Trace (if applicable)

Cannot find module '@langchain/core/callbacks' or its corresponding type declarations.ts

Description

System Info


@langchain/core@0.3.9 | MIT | deps: 11 | versions: 161
Core LangChain.js abstractions and schemas
https://github.com/langchain-ai/langchainjs/tree/main/langchain-core/

keywords: llm, ai, gpt3, chain, prompt, prompt engineering, chatgpt, machine learning, ml, openai, embeddings, vectorstores

dist
.tarball: https://registry.npmjs.org/@langchain/core/-/core-0.3.9.tgz
.shasum: 1fa75be84a22d951946277bc4ad3ea656c77fafc
.integrity: sha512-Rttr9FuFwU+CWIoEyuLqQUPYg+3pKL1YpDgo3nvoDVhinoHqwGQ7aNGzZ/Sf+qASMi76sPSLm+75pHMJwwOiWg==
.unpackedSize: 2.2 MB

dependencies:
ansi-styles: ^5.0.0         js-tiktoken: ^1.0.12        p-queue: ^6.6.2             zod-to-json-schema: ^3.22.3 
camelcase: 6                langsmith: ^0.1.56          p-retry: 4                  zod: ^3.22.4                
decamelize: 1.2.0           mustache: ^4.2.0            uuid: ^10.0.0               

maintainers:
- eric_langchain <eric@langchain.dev>
- maddyadams <madelyn.adams1@gmail.com>
- sam_noyes <sam@langchain.dev>
- vbarda <vadym@langchain.dev>
- davidduong <david@duong.cz>
- andrewnguonly <andrewnguonly@gmail.com>
- basproul <braceasproul@gmail.com>
- jacoblee93 <jacoblee93@gmail.com>
- nfcampos <nuno@boringbits.io>
- sullivan-sean <ssullivan61198@gmail.com>
- hwchase17 <hw.chase.17@gmail.com>

dist-tags:
latest: 0.3.9                              tag-for-publishing-older-releases: 0.2.36  
next: 0.3.10-rc.0                          

published 2 days ago by jacoblee93 <jacoblee93@gmail.com>

Platform: Linux

Nodejs Version: v20.17.0

We are using pnpm, therefore pnpm version: 9.12.1

dosubot[bot] commented 1 week ago

Hey there, @tbhaxor! I'm here to help you with bug fixes, answer questions, and guide you on becoming a contributor. Let's work on resolving the issue together.

The issue you're encountering is because the @langchain/core package does not export a module directly under callbacks. Instead, it exports specific submodules like callbacks/base, callbacks/dispatch, etc.

To resolve this, you should import from one of the specific submodule paths:

import { someFunction } from '@langchain/core/callbacks/base';

Make sure to use the correct submodule path as per the exports configuration [1].

To continue talking to Dosu, mention @dosu.