Skip to content

Typing issue with langchain, @langchain/core, and @langchain/openai #5736

Closed
@AumeshMisra

Description

@AumeshMisra

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain.js documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain.js rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

const prompt = PromptTemplate.fromTemplate(myPrompt);
const model = new AzureOpenAI({
modelName: "gpt-4o",
temperature: 0.0,
});

const combineDocsChain = await createStuffDocumentsChain({
  llm: model,
  prompt,
});

const chain = await createRetrievalChain({
  retriever,
  combineDocsChain,
});

Error Message and Stack Trace (if applicable)

No response

Description

I am trying to use createStuffDocumentsChain but it's unable to resolve types.

For the llm param, I get:

Type 'AzureOpenAI' is not assignable to type 'LanguageModelLike'.
  Property 'lc_runnable' is protected but type 'Runnable<RunInput, RunOutput, CallOptions>' is not a class derived from 'Runnable<RunInput, RunOutput, CallOptions>'.

for the prompt param, I get:
The expected type comes from property 'prompt' which is declared here on type '{ llm: LanguageModelLike; prompt: BasePromptTemplate<any, BasePromptValueInterface, any>; outputParser?: BaseOutputParser<...> | undefined; documentPrompt?: BasePromptTemplate<...> | undefined; documentSeparator?: string | undefined; }'

This was fine when I had:
"@langchain/community": "^0.2.4",
"@langchain/core": "^0.2.2",
"@langchain/openai": "^0.0.34",

But now there's an error when I have:
"@langchain/community": "^0.2.4",
"@langchain/core": "^0.2.6",
"@langchain/openai": "^0.1.2",

I even made sure to add:
"langchain": "^0.2.5",
but I'm still getting issues there.

System Info

"@langchain/core": "^0.2.6",
"@langchain/openai": "^0.1.2",
"@langchain/pinecone": "0.0.6",
"@pinecone-database/pinecone": "^2.2.2",
"@prisma/client": "^5.14.0",
"axios": "^1.6.8",
"body-parser": "^1.20.2",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"express": "^4.19.2",
"langchain": "^0.2.5",

Metadata

Metadata

Assignees

No one assigned

    Labels

    auto:bugRelated to a bug, vulnerability, unexpected error with an existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions