Closed gognjanovski closed 1 week ago
Hello @gognjanovski! I'm here to help you with your LangChain.js issue. I'm a bot designed to assist with bug fixes, questions, and contributions. Let's work together to resolve the issue you're experiencing.
I found some relevant information that might help with the issue you're facing.
Similar Issues and Discussions:
Possible Cause and Solution:
ParsedChatCompletion
is being imported from a module that does not exist or is not correctly referenced in your project. Verify the correct path and export for ParsedChatCompletion
in the openai
package or remove the import if it is not needed [4].ParsedChatCompletion
is a valid export in the openai/resources/beta/chat/completions.mjs
file. According to the LangChain.js repository, it is a valid export [4].Dependencies:
package.json
file. The relevant dependencies are:
"openai": "^4.41.1"
and peer dependencies:
"@langchain/openai": ">=0.1.0 <0.3.0"
Ensure these are correctly installed and compatible with your project [5].
Alternative Methods:
ParsedChatCompletion
. You can use Runnable
, RunnablePassthrough
, and RunnableSequence
for structured output methods. Here is an example:
withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(
outputSchema: StructuredOutputMethodParams<RunOutput, boolean> | z.ZodType<RunOutput> | Record<string, any>,
config?: StructuredOutputMethodOptions<boolean>
): Runnable<BaseLanguageModelInput, RunOutput> | Runnable<BaseLanguageModelInput, { raw: BaseMessage; parsed: RunOutput }> {
// Implementation details...
}
This code snippet demonstrates how to use structured output methods with Runnable
, RunnablePassthrough
, and RunnableSequence
to achieve similar functionality [6][4].
By following these steps, you should be able to resolve the import error and continue building your Node.js project with the LangChain package.
To continue talking to Dosu, mention @dosu.
Hey, sorry for the delay here!
Will fix.
Live in @langchain/openai@0.2.10
!
Example Code
I get the following error
node_modules/@langchain/openai/dist/chat_models.d.ts:9:38 - error TS7016: Could not find a declaration file for module 'openai/resources/beta/chat/completions.mjs'.
forimport { ParsedChatCompletion } from "openai/resources/beta/chat/completions.mjs";
Error Message and Stack Trace (if applicable)
No response
Description
I'm trying to build my nodejs project that includes the langchain package
System Info
Using: node v20.13.1 npm 10.5.2 "langchain": "^0.2.17" "openai": "4.57.0"