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

Compilation errors #56

Closed
sonicviz opened this issue Jul 29, 2024 · 4 comments
Closed

Compilation errors #56

sonicviz opened this issue Jul 29, 2024 · 4 comments

Comments

@sonicviz
Copy link

sonicviz commented Jul 29, 2024

  • I'm submitting a ...
    [ ] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [X ] question about how to use this project

  • Summary

Looks like a great project so I decided to test it out with a https://quasar.dev/ js project.
This is compatible with ts package imports, so I imported as per the guide.

So, the issue is I imported https://github.com/ax-llm/ax aok as per npm install @ax-llm/ax did a quasar build and my project is aok. Runs fine.
It's when I go to use AX strange things begine to happen.
If I add the following line to a file import { AxAgent, AxAI, AxFunction, AxSignature } from '@ax-llm/ax'; in preparation for using it I immediately get compilation error #1:

Compilation error 1: [Resolved]
Syntax Error: Reading from "node:fs" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.

I fixed this by modifying the quaser.config chain webpack:
chainWebpack(chain) {
chain
.plugin("eslint-webpack-plugin")
.use(ESLintPlugin, [{ extensions: ["js", "vue"] }]),
chain.merge({
externals: {
"node:fs": "commonjs util",
},
});
},
},

So that passed, but then I got another bunch of compilation errors, which I copy just below.
I tried importing one out of interest [npm install --save stream/web] but that failed with fatal: Could not read from remote repository.

Any clues as to what is going on here? Would love to test it out in an integration project.
I ran the examples locally ok, just trying to integrate it into a basic Quasar js project doesn't seem to work too well.
Thanks!

Compilation errors #2 [Unresolved]

App • ERROR • UI in ./node_modules/@ax-llm/ax/ai/util.js

Module not found: Can't resolve imported dependency "crypto"
Did you forget to install it? You can run: npm install --save crypto

App • ERROR • UI in ./node_modules/@ax-llm/ax/dsp/generate.js

Module not found: Can't resolve imported dependency "stream/web"
Did you forget to install it? You can run: npm install --save stream/web

App • ERROR • UI in ./node_modules/@ax-llm/ax/dsp/sig.js

Module not found: Can't resolve imported dependency "crypto"
Did you forget to install it? You can run: npm install --save crypto

App • ERROR • UI in ./node_modules/@ax-llm/ax/funcs/code.js

Module not found: Can't resolve imported dependency "crypto"
Did you forget to install it? You can run: npm install --save crypto

App • ERROR • UI in ./node_modules/@ax-llm/ax/funcs/code.js

Module not found: Can't resolve imported dependency "http"
Did you forget to install it? You can run: npm install --save http

App • ERROR • UI in ./node_modules/@ax-llm/ax/funcs/code.js

Module not found: Can't resolve imported dependency "https"
Did you forget to install it? You can run: npm install --save https

App • ERROR • UI in ./node_modules/@ax-llm/ax/funcs/code.js

Module not found: Can't resolve imported dependency "os"
Did you forget to install it? You can run: npm install --save os

App • ERROR • UI in ./node_modules/@ax-llm/ax/funcs/code.js

Module not found: Can't resolve imported dependency "process"
Did you forget to install it? You can run: npm install --save process

App • ERROR • UI in ./node_modules/@ax-llm/ax/funcs/code.js

Module not found: Can't resolve imported dependency "vm"
Did you forget to install it? You can run: npm install --save vm

App • ERROR • UI in ./node_modules/@ax-llm/ax/util/apicall.js

Module not found: Can't resolve imported dependency "path"
Did you forget to install it? You can run: npm install --save path

App • ERROR • UI in ./node_modules/@ax-llm/ax/util/apicall.js

Module not found: Can't resolve imported dependency "stream/web"
Did you forget to install it? You can run: npm install --save stream/web

App • COMPILATION FAILED • Please check the log above for details.

  • Other information (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)
@karol-f
Copy link
Contributor

karol-f commented Jul 29, 2024

Hi, this errors occur when you try to use Node.js modules like crypto or http in browser evirinment. Please make sure you use Ax library properly, on Node.js side and don't leak it to browser.

You can e.g. use dunamic imports in your code like:

if (typeof window === 'undefined') {
    const { util } = await import('@ax-llm/ax');
}

@sonicviz
Copy link
Author

sonicviz commented Jul 29, 2024

Thanks for the quick reply. I see, I'll use it a cloud function instead.
It wasn't clear to me it's a server side package only, those dependencies don't appear until you try to use it as an import.
I'm just prototyping atm, to get a feel for Ax.
Thanks!

@karol-f
Copy link
Contributor

karol-f commented Jul 29, 2024

It makes sense to keep it server-only as there are your API keys for OpenAI or Anthropic LLM models, and you don't want to share them with every internet user :) You might not like the bill for API usage after that :)

@sonicviz
Copy link
Author

sonicviz commented Jul 29, 2024

Sure, though there are a variety of methods for keeping keys reasonably secure client side.
That said, I also prefer to use cloud functions (on Appwrite atm) once I have the code worked out. It's quicker iterating in the browser initially though, when doing local dev - though pushing to a function with an auto CI build isn't that much more once you have it set up.

Just a suggestion, but might be good to highlight the fact in the docs it's for server side use, just to make things clear up front.
Thanks!

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