Open fjnoyp opened 1 month ago
Hey @fjnoyp! 👋 I'm here to help you with bug fixes, answer questions, and guide you to become a contributor. Let's squash those bugs together!
To resolve the type mismatch error in Deno when using different versions of @langchain/core
with ChatOpenAI
and ChatGroq
, you need to ensure that all related packages are using the same version of @langchain/core
. In your import_map.json
, you have specified @langchain/core
as version 0.2.29
, but it seems that ChatOpenAI
is still using a different version.
Update your import_map.json
to ensure that both langchain/
and @langchain/core/
are using the same version. For example, you can set both to 0.2.29
:
{
"imports": {
"http/": "https://deno.land/std@0.177.0/http/",
"langchain/": "https://esm.sh/v135/langchain@0.2.29/",
"@langchain/core/": "https://esm.sh/v135/@langchain/core@0.2.29/",
"@langchain/groq": "https://esm.sh/v135/@langchain/groq@0.0.17/",
"@langchain/openai": "https://esm.sh/v135/@langchain/openai@0.3.0/",
"@langchain/cohere": "https://esm.sh/v135/@langchain/cohere@0.2.2/",
"langsmith/": "https://esm.sh/v135/langsmith@0.1.43/",
"zod": "https://esm.sh/v135/zod@3.23.8/"
},
"scopes": {
"https://esm.sh/v135/": {
"@langchain/core": "https://esm.sh/v135/@langchain/core@0.2.29/"
},
"https://esm.sh/v135/@langchain/openai@0.3.0/": {
"@langchain/core/": "https://esm.sh/v135/@langchain/core@0.2.29/"
}
}
}
Additionally, ensure that the imports for ChatOpenAI
and ChatGroq
are correctly aligned with the same version of @langchain/core
. The _initChatModelHelper
function in langchain/src/chat_models/universal.ts
dynamically imports the appropriate chat model based on the provider, ensuring that the correct version is used. This should help in maintaining consistency across different chat models and avoid type mismatches [1][2].
For more information on installation and ensuring consistent versions, refer to the LangChain installation guide. It is crucial to ensure that all packages in the LangChain ecosystem depend on the same version of @langchain/core
to avoid type errors [3].
To continue talking to Dosu, mention @dosu.
Checked other resources
Example Code
Deno import_map.json
NOTE: I get the type mismatch error if I do not manually find and choose the version of langchain/groq that uses the exact same version of langchain/core.
Code Usage
Error Message and Stack Trace (if applicable)
I get what appears to be a type mismatch because my openai import uses a different version langchain/core ...
Description
I'm trying to import langchain as part of my supabase edge function deno environment. Despite using scopes to force a common version of langchain/core the type mismatch error persists (https://js.langchain.com/docs/how_to/installation/#installing-integration-packages).
I've read online trying many different variations on scopes to fix this but keep getting the same type mismatch. I wrote a detailed stack overflow question with the other variations I tried as well: https://stackoverflow.com/questions/78941151/langchain-deno-import-map-cannot-use-common-langchain-core
When I go into ChatOpenAI class such as: https://esm.sh/v135/@langchain/openai@0.3.0/dist/chat_model.d.ts
I see it always using:
import { Runnable } from "https://esm.sh/v135/@langchain/core@0.2.32/runnables.d.ts";
Even though I specified the scope:I have reloaded and cleared the deno cache multiple times: deno cache --reload ./ai_logic.ts --import-map=../../import_map.json
I'm unsure if this is a bug with deno or langchain but it does not seem possible to properly resolve to the same version of langchain/core.
Thank you in advance for your help and consideration here.
System Info
.vscode/settings.json
full import_map.json