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

bug: @core/llamaindex doesn't allow access to various schemas #987

Closed
parhammmm opened this issue Jun 27, 2024 · 8 comments
Closed

bug: @core/llamaindex doesn't allow access to various schemas #987

parhammmm opened this issue Jun 27, 2024 · 8 comments

Comments

@parhammmm
Copy link
Contributor

parhammmm commented Jun 27, 2024

Attempting to import the following from @core/llamaindex and getting Cannot find declarations

Document
Metadata
BaseNode
MetadataMode
NodeWithScore

// Doesn't work:
import { Document } from "@llamaindex/core";

// Doesn't work
import { Document } from "@llamaindex/core/schema";

// Works for import but gives `Error: Missing "./dist/schema" specifier in "@llamaindex/core" package`
import { Document } from "@llamaindex/core/dist/schema";

any tips @himself65 ?

P.S. I think this is a good direction, just need to figure out the above

@himself65
Copy link
Member

change module resolution to node16 or bundler in your tsconfig

@parhammmm
Copy link
Contributor Author

@himself65 thanks! switching to bundler has resolved it

@himself65
Copy link
Member

nit: always use bundler if you are not running code like tsc && node ./dist/index.js

@parhammmm
Copy link
Contributor Author

@himself65 I'm trying to find a work around right now but setting to bundler might not always be possible

more context: building or azure functions app

@himself65
Copy link
Member

himself65 commented Jul 2, 2024

@himself65 I'm trying to find a work around right now but setting to bundler might not always be possible

more context: building or azure functions app

I don't have much further idea about this, but this is ts old behavior. But whether you update your tsconfig.json, do some patches to make type check happy, or use a bundler to a single js file before releasing to the Azure function app.

maybe related issue: microsoft/TypeScript#46452

llamaindex-ts targeting to > node.js 18, and recent typescript > 4.7 so I don't want to support legacy node and ts

@parhammmm
Copy link
Contributor Author

@himself65 apologies totally forgot to update you on this.

That's fair and very reasonable not want to support anything below node18.

In the end I managed to work around everything bit by bit to get the build working.

The one thing that was frustrating and I figured out in the end was, prettier had to be re-configured too, renaming it's config from .prettierrc.js to .prettierrc.json forced it to use modules in the end

@himself65
Copy link
Member

do you mean cjs to esm?

@parhammmm
Copy link
Contributor Author

Yep

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants