-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Error TS2415: Class 'ChatOpenAI<CallOptions>' incorrectly extends base class 'BaseChatModel<CallOptions, AIMessageChunk>' #5675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
To resolve the TypeScript compilation error related to
Here is an example of how you might configure your FROM node:18
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
COPY package*.json ./
RUN npm install
# Bundle app source
COPY . .
# Build the TypeScript code
RUN npm run build
# If you have a start script
CMD [ "npm", "start" ] And ensure your {
"compilerOptions": {
"target": "ES6",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"outDir": "./dist"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/*.spec.ts"]
} Additionally, ensure that your environment variables are correctly set in your Docker environment. You can do this by adding the following to your # Set environment variables
ENV OPENAI_API_KEY=<your_openai_api_key>
ENV AZURE_OPENAI_API_KEY=<your_azure_openai_api_key>
ENV AZURE_OPENAI_API_INSTANCE_NAME=<your_azure_instance_name>
ENV AZURE_OPENAI_API_DEPLOYMENT_NAME=<your_azure_deployment_name>
ENV AZURE_OPENAI_API_VERSION=<your_azure_api_version> If the issue persists, you might need to provide more specific error messages or logs to diagnose further. Additionally, ensure that the import { ChatOpenAI } from "@langchain/openai";
// Example usage
const model = new ChatOpenAI({
temperature: 0.9,
model: "ft:gpt-3.5-turbo-0613:{ORG_NAME}::{MODEL_ID}",
});
const message = await model.invoke("Hi there!");
console.log(message); Make sure that all required environment variables and configurations are correctly set up as described in the |
I created this repo to easily reproduce the bug in 4 easy steps. It turns out that this problem even occurs outside of docker build step: https://github.com/johnnyoshika/langchain-ts2415 Demo: demo.mov |
I can confirm that I am facing a related issue when I am trying to do something like the following:
I get the following error:
|
Sorry you were getting this error! If you upgrade to the latest version of We're taking steps to add tests for this, so this type of issue can be caught in the future. |
@bracesproul thanks for the quick fix! |
Hi @bracesproul, I am seeing a similar issue with: #5736 even with the latest packages. |
Checked other resources
Example Code
Compiling a project that uses
ChatOpenAI
from @langchain/openai during a Docker build results in an error. To reproduce:package.json:
Dockerfile:
docker build --no-cache -t container-name .
Error Message and Stack Trace (if applicable)
Description
I'm trying to build a project inside of a Docker build process and it fails with the error listed above.
I have to enable
"skipLibCheck": true
in my tsconfig.json in order to get around this problem.Note that running the same command (
npm run build
, which runstsc
) directly in macOS or Windows does not result in this error. It seems to only occur during a docker build.System Info
Node: 18
[email protected]
[email protected]
@langchain/[email protected]
Running
docker build --no-cache -t container-name .
command in macOS Terminal.The text was updated successfully, but these errors were encountered: