Skip to content
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

Type error to do with BaseLanguageModel and CallOptions #3793

Closed
5-tom opened this issue Dec 26, 2023 · 9 comments
Closed

Type error to do with BaseLanguageModel and CallOptions #3793

5-tom opened this issue Dec 26, 2023 · 9 comments
Assignees
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@5-tom
Copy link

5-tom commented Dec 26, 2023

Introduced here I believe: #3709

0.0.203 is a working version.

Stack trace:

node_modules/@langchain/core/dist/language_models/base.d.ts:122:31 - error TS2420: Class 'BaseLanguageModel<RunOutput, CallOptions>' incorrectly implements interface 'BaseLanguageModelInterface<RunOutput, CallOptions>'.
  Property 'CallOptions' is missing in type 'BaseLanguageModel<RunOutput, CallOptions>' but required in type 'BaseLanguageModelInterface<RunOutput, CallOptions>'.

122 export declare abstract class BaseLanguageModel<RunOutput = any, CallOptions extends BaseLanguageModelCallOptions = BaseLanguageModelCallOptions> extends BaseLangChain<BaseLanguageModelInput, RunOutput, CallOptions> implements BaseLanguageModelParams, BaseLanguageModelInterface<RunOutput, CallOptions> {
                                  ~~~~~~~~~~~~~~~~~

  node_modules/@langchain/core/dist/language_models/base.d.ts:104:62
    104 export interface BaseLanguageModelInterface<RunOutput = any, CallOptions extends BaseLanguageModelCallOptions = BaseLanguageModelCallOptions> extends RunnableInterface<BaseLanguageModelInput, RunOutput, CallOptions> {
                                                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    'CallOptions' is declared here.


Found 1 error in node_modules/@langchain/core/dist/language_models/base.d.ts:122
Copy link

dosubot bot commented Dec 26, 2023

🤖

It's great to see that you've identified an issue and are looking to contribute to langchainjs! Your effort is much appreciated. I encourage you to go ahead and create a pull request with your proposed solution to address this type error. The maintainers will review your PR and determine if the change should be merged. Keep up the good work!


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.

@dosubot dosubot bot added the auto:bug Related to a bug, vulnerability, unexpected error with an existing feature label Dec 26, 2023
@YarivLevy81
Copy link

I'm having the same issue, can't use latest version. any workaround besides of using 0.0.203?

@vinayr
Copy link

vinayr commented Jan 2, 2024

Workaround: Add "skipLibCheck": true to your tsconfig.json

{
  "compilerOptions": {
    .....
    "skipLibCheck": true,
  }
}

@mieslep
Copy link
Contributor

mieslep commented Jan 8, 2024

having same problem, using workaround. FYI @jacoblee93 something strange going on here...

@jacoblee93
Copy link
Collaborator

jacoblee93 commented Jan 8, 2024

Thanks for the heads up and sorry for missing this - the workaround is good but is there a code example/package.json/tsconfig.json that I can use to repro this?

If you have multiple packages installed do the instructions here fix it?

https://js.langchain.com/docs/get_started/installation#installing-integration-packages

@jacoblee93 jacoblee93 self-assigned this Jan 8, 2024
@jacoblee93
Copy link
Collaborator

@mieslep perhaps?

@5-tom
Copy link
Author

5-tom commented Jan 8, 2024

Thanks for the heads up and sorry for missing this - the workaround is good but is there a code example/package.json/tsconfig.json that I can use to repro this?

If you have multiple packages installed do the instructions here fix it?

https://js.langchain.com/docs/get_started/installation#installing-integration-packages

I've had no luck following the linked instructions. Here's what you can use to reproduce the errors:

package.json

{
	"type": "module",
	"scripts": {
		"broken": "tsc -m nodenext main.ts",
		"works": "tsc -m nodenext --skipLibCheck main.ts"
	},
	"dependencies": {
		"@langchain/openai": "latest"
	},
	"devDependencies": {
		"typescript": "latest"
	}
}

main.ts

import { ChatOpenAI } from "@langchain/openai";

@jacoblee93
Copy link
Collaborator

jacoblee93 commented Jan 8, 2024

How about a tsconfig.json` file @5-tom?

And it doesn't look like you have langchain installed?

Edit: Never mind, I am able to repro with tsc.

I see:

node_modules/@langchain/core/dist/language_models/base.d.ts:130:31 - error TS2420: Class 'BaseLanguageModel<RunOutput, CallOptions>' incorrectly implements interface 'BaseLanguageModelInterface<RunOutput, CallOptions>'.
  Property 'CallOptions' is missing in type 'BaseLanguageModel<RunOutput, CallOptions>' but required in type 'BaseLanguageModelInterface<RunOutput, CallOptions>'.

130 export declare abstract class BaseLanguageModel<RunOutput = any, CallOptions extends BaseLanguageModelCallOptions = BaseLanguageModelCallOptions> extends BaseLangChain<BaseLanguageModelInput, RunOutput, CallOptions> implements BaseLanguageModelParams, BaseLanguageModelInterface<RunOutput, CallOptions> {
                                  ~~~~~~~~~~~~~~~~~

  node_modules/@langchain/core/dist/language_models/base.d.ts:104:62
    104 export interface BaseLanguageModelInterface<RunOutput = any, CallOptions extends BaseLanguageModelCallOptions = BaseLanguageModelCallOptions> extends RunnableInterface<BaseLanguageModelInput, RunOutput, CallOptions> {
                                                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    'CallOptions' is declared here.

node_modules/@langchain/core/dist/utils/stream.d.ts:1:18 - error TS2320: Interface 'IterableReadableStreamInterface<T>' cannot simultaneously extend types 'ReadableStream<T>' and 'AsyncGenerator<T, any, unknown>'.
  Named property '[Symbol.asyncIterator]' of types 'ReadableStream<T>' and 'AsyncGenerator<T, any, unknown>' are not identical.

1 export interface IterableReadableStreamInterface<T> extends ReadableStream<T>, AsyncGenerator<T> {
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@langchain/core/dist/utils/stream.d.ts:9:5 - error TS2425: Class 'ReadableStream<T>' defines instance member property '[Symbol.asyncIterator]', but extended class 'IterableReadableStream<T>' defines it as instance member function.

9     [Symbol.asyncIterator](): this;
      ~~~~~~~~~~~~~~~~~~~~~~


@jacoblee93
Copy link
Collaborator

I think #3953 fixes this! Can you try locking your core version to 0.1.11?

I was occasionally able to repro another typing bug caused by a polyfill overriding a global stream in that OpenAI's SDK uses. Please reopen another issue if you see this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature
Projects
None yet
Development

No branches or pull requests

5 participants