ax-llm / ax

The unofficial DSPy framework. Build LLM powered Agents and "Agentic workflows" based on the Stanford DSP paper.
http://axllm.dev
Apache License 2.0
1.05k stars 70 forks source link

Named export 'AxAI' not found when importing #47

Closed Herbak closed 3 months ago

Herbak commented 3 months ago
import { AxAI, AxChainOfThought } from '@ax-llm/ax';
         ^^^^
SyntaxError: Named export 'AxAI' not found. The requested module '@ax-llm/ax' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from '@ax-llm/ax';
const { AxAI, AxChainOfThought } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:171:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:254:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:475:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:109:5)

Note : I use vanilla JS, not TS

Herbak commented 3 months ago

Solved adding "type": "module" in the package.json of the @ax-llm/ax node module

karol-f commented 3 months ago

Checking...

karol-f commented 3 months ago

Fixed in https://github.com/ax-llm/ax/pull/48

It was tested on both:

in plain Node.js - everything works as expected.

CC @dosco