langchainjs: Opensearch integration compilation error
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
I am following these instructions in an empty typescript project:
https://js.langchain.com/docs/integrations/vectorstores/opensearch
It cannot compile
here is my package.json
{
"name": "utils",
"version": "1.0.0",
"description": "",
"main": "utils.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "node_modules/typescript/bin/tsc"
},
"author": "",
"license": "ISC",
"dependencies": {
"@aws-sdk/client-apigatewaymanagementapi": "^3.525.0",
"@aws-sdk/client-dynamodb": "^3.525.0",
"@aws-sdk/lib-dynamodb": "^3.525.0",
"@langchain/openai": "^0.0.22",
"@opensearch-project/opensearch": "^2.6.0",
"@types/aws-lambda": "^8.10.130",
"@types/node": "^20.10.5",
"langchain": "^0.1.28",
"openai": "^4.24.2",
"uuid": "^9.0.1"
},
"devDependencies": {
"@types/uuid": "^9.0.8",
"jest": "^29.7.0"
},
"overrides": {
"@langchain/core": "0.1.5"
}
}
Error Message and Stack Trace (if applicable)
$ tsc node_modules/@langchain/openai/dist/chat_models.d.ts:7:64 - error TS2305: Module ‘“@langchain/core/language_models/base”’ has no exported member ‘StructuredOutputMethodOptions’.
7 import type { BaseFunctionCallOptions, BaseLanguageModelInput, StructuredOutputMethodOptions, StructuredOutputMethodParams } from “@langchain/core/language_models/base”; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@langchain/openai/dist/chat_models.d.ts:7:95 - error TS2305: Module ‘“@langchain/core/language_models/base”’ has no exported member ‘StructuredOutputMethodParams’.
7 import type { BaseFunctionCallOptions, BaseLanguageModelInput, StructuredOutputMethodOptions, StructuredOutputMethodParams } from “@langchain/core/language_models/base”; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@langchain/openai/dist/utils/openai.d.ts:3:62 - error TS2307: Cannot find module ‘@langchain/core/utils/function_calling’ or its corresponding type declarations.
3 import { convertToOpenAIFunction, convertToOpenAITool } from “@langchain/core/utils/function_calling”; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@langchain/openai/dist/utils/openai.d.ts:6:103 - error TS2724: ‘“/Users/howardkitto/Projects/Intentional/intentional-api/layers/utils/node_modules/openai/resources/beta/beta”.Beta’ has no exported member named ‘AssistantCreateParams’. Did you mean ‘AssistantUpdateParams’?
6 export declare function formatToOpenAIAssistantTool(tool: StructuredToolInterface): OpenAIClient.Beta.AssistantCreateParams.AssistantToolsFunction; ~~~~~~~~~~~~~~~~~~~~~
node_modules/@langchain/openai/node_modules/@langchain/core/dist/language_models/chat_models.d.ts:64:129 - error TS2304: Cannot find name ‘this’.
64 _generateCached({ messages, cache, llmStringKey, parsedOptions, handledOptions, }: ChatModelGenerateCachedParameters<typeof this>): Promise<LLMResult & { ~~~~
node_modules/@langchain/openai/node_modules/@langchain/core/dist/language_models/llms.d.ts:66:122 - error TS2304: Cannot find name ‘this’.
66 _generateCached({ prompts, cache, llmStringKey, parsedOptions, handledOptions, }: LLMGenerateCachedParameters<typeof this>): Promise<LLMResult & { ~~~~
Found 6 errors in 4 files.
Errors Files 2 node_modules/@langchain/openai/dist/chat_models.d.ts:7 2 node_modules/@langchain/openai/dist/utils/openai.d.ts:3 1 node_modules/@langchain/openai/node_modules/@langchain/core/dist/language_models/chat_models.d.ts:64 1 node_modules/@langchain/openai/node_modules/@langchain/core/dist/language_models/llms.d.ts:66
Description
The documentation is wrong The dependencies are not up to date
System Info
mac aws lambda (SAM)
About this issue
- Original URL
- State: closed
- Created 3 months ago
- Reactions: 2
- Comments: 15
@roshie548
npm i -S openai@4.26.0work here. Thanks !!!npm i -S openai@4.26.0fixed theAssistantCreateParamserror for me.From the error messages you’ve shared, it seems like there are a few issues related to the
@langchain/openaiand@langchain/corepackages. Let’s address them one by one:Error in
openai.d.ts: The error message suggests that theAssistantCreateParamsmember is not exported from theBetamodule. This could be due to a version mismatch between@langchain/openaiandopenai. You’re using@langchain/openaiversion^0.0.22andopenaiversion^4.24.2. Please ensure that these versions are compatible. If the error persists, you might need to use a different member that exists in theBetamodule, as suggested by the error message (AssistantUpdateParams).Errors in
chat_models.d.tsandllms.d.ts: These errors are related to the usage ofthisin a type parameter context. This is a TypeScript feature that allows a class method to refer to the class instance type withthis. However, it seems like the TypeScript compiler is unable to resolvethisin the context where it’s used. This could be due to a TypeScript version mismatch or a bug in the@langchain/corepackage. You’re using TypeScript version^5.4.3, please ensure that this version is compatible with@langchain/core.To resolve these issues, you could try the following steps:
@langchain/openaiandopenaipackages to the latest versions, if they’re not already. This could potentially resolve the issue if it’s due to a bug that has been fixed in a newer version.@langchain/openaiandopenaidocumentation to ensure that you’re using theBetamodule correctly. IfAssistantCreateParamsis not available, you might need to use a different member.chat_models.d.tsandllms.d.tsas a workaround. However, please note that this is not a recommended practice as it could lead to other issues.If none of the above steps resolve the issue, please provide more information about your TypeScript configuration and the exact steps to reproduce the issue. This would help in identifying the root cause of the issue and finding a suitable solution.
Sources
About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
Hey there @HowardIntentional! Good to see you back with us 🚀
Thank you for providing detailed information about the issue you’re encountering. It seems like there might be a few different factors contributing to the compilation error.
Firstly, the error messages suggest that there are some unresolved imports in your
opensearch.tsfile. Specifically, theStructuredOutputMethodOptionsandStructuredOutputMethodParamsmodules from the@langchain/core/language_models/basepackage seem to be causing issues. Unfortunately, I wasn’t able to find the correct import paths for these modules within the repository. It’s possible that these modules have been moved, renamed, or removed in a recent update to the@langchain/corepackage.Secondly, the error messages also indicate that there might be some version compatibility issues between the
@langchain/coreand@langchain/openaipackages. The@langchain/corepackage version compatible with LangChain JS version 0.1.28 is~0.1.45, and the@langchain/openaipackage version is0.0.22. Please ensure that you’re using these versions in your project.Lastly, the error messages suggest that there might be some issues with your TypeScript configuration. Specifically, the
Cannot find name 'this'errors inchat_models.d.tsandllms.d.tsmight be due to some TypeScript compiler options that are causing the resolution to fail. Please check yourtsconfig.jsonfor any configurations that might affect module resolution.Unfortunately, I wasn’t able to find any known issues or bugs with the Opensearch integration in the LangChain JS version 0.1.28, or any discrepancies between the LangChain JS documentation and the actual implementation that could be causing your issue. However, it’s possible that I might have missed something, or that the answer may be available elsewhere.
If you’re still encountering the issue after checking these potential causes, could you please provide more information about your TypeScript configuration and the exact steps you’re following to integrate Opensearch with LangChain.js? This will help us to better understand the issue and provide a more accurate solution.
Sources
About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
Bumping to latest langchain@0.1.31 and @langchain/openai@0.0.26 should fix the most recent iteration of this - apologies for the delay!