Imports
Scripts using the .mjs
extension can use static or dynamic imports as any other module file.
You can rename any .genai.js
file to .genai.mjs
to enable module imports.
Module Imports
You can import node packages installed in your project.
JavaScript imports
You can also import other local JavaScript files (using static or dynamic imports).
- static import (
import ... from ...
)
- dynamic import (
async import(...)
)
TypeScript imports
TypeScript module files (.mts
) can be imported using dynamic import only.
- dynamic import (
async import(...)
)
env.generator
The env.generator
references the root prompt generator context, the top level $
, def
functions… It can be used to create function that can be used with those function or also with runPrompt
.
Default function export
If you set a function as the default export, GenAIScript will call it. The function can be async.