Overview
GenAIScript are JavaScript files named as *.genai.mjs
, or TypeScript files named as *.genai.mts
,
with a prompt creation engine designed by LLM prompting.
Script files
- GenAIScript will detect any file matching
*.genai.mjs
,*.genai.js
,*.genai.mts
in your workspace. - GenAIScript files can be placed anywhere in your workspace;
but the extension will place them in a
genaisrc
folder by default. .genai.mjs
use module JavaScript syntax and support imports..genai.js
are eval-ed and do not support imports..genai.mts
are TypeScript module files and support imports, including dynamic imports of other TypeScript files.
Directory/genaisrc
- jsconfig.json // TypeScript compiler configuration
- genaiscript.d.ts // TypeScript definitions
- myscript.genai.mjs // your script!
- …
system.*.genai.mjs
are considered system prompt templates and are unlisted by default.
Topics
Cancel Learn how to immediately stop script execution with the cancel function in your automation scripts.
Metadata Learn how to configure script metadata to enhance functionality and user experience in GenAIScript.
Prompt ($) Learn how to use the tagged template literal for dynamic prompt generation in GenAI scripts.
Context (env+def) Detailed documentation on the script execution context and environment variables in GenAIScript.
Variables Discover how to utilize and customize script variables for dynamic scripting capabilities with env.vars.
File Output Learn how to declare and manage script-generated file outputs with defFileOutput function.
Tools Learn how to define and use tools within GenAIScript to enhance answer assembly with custom logic and CLI tools.
Data Schemas Learn how to define and use data schemas for structured output in JSON/YAML with LLM, including validation and repair techniques.
Agents An Agent is a tool that queries an LLM, equipped with other tools, to accomplish tasks.
DOCX Learn how to parse and extract text from DOCX files for text analysis and processing.
PDF Learn how to extract text from PDF files for prompt generation using GenAIScript's PDF parsing capabilities.
XML Learn how GenAIScript automatically parses XML files and converts them to JSON objects for easier handling and manipulation.
Markdown Enhance your markdown capabilities with MD class helpers for parsing and managing frontmatter efficiently.
Images Learn how to add images to prompts for AI models supporting visual inputs, including image formats and usage.
Inline prompts Learn how to use inline prompts with runPrompt function for inner LLM invocations in scripting.
Retrieval Learn how to use GenAIScript's retrieval utilities for content search and prompt augmentation with RAG techniques.
System Prompts Learn how to utilize system prompts to enhance script execution in GenAIScript.
Vector Search Learn how to use the retrieval.vectorSearch function to index files with embeddings for efficient similarity search in vector databases.
Annotations Learn how to add annotations such as errors, warnings, or notes to LLM output for integration with VSCode or CI environments.
File Merge Customize file merging in scripts with defFileMerge function to handle different file formats and merging strategies.
Tests Learn how to execute and evaluate LLM output quality with promptfoo, a tool designed for testing language model outputs.
Custom Output Learn how to use the defOutputProcessor function for custom file processing in script generation.
JSON Mode Learn how to enable JSON output mode in scripts for structured data generation with OpenAI's platform.
Parsers Comprehensive guide on various data format parsers including JSON5, YAML, TOML, CSV, PDF, DOCX, and token estimation for LLM.
Structured Output Utilize structured output in GenAIScript to generate JSON data with schema validation for precise and reliable data structuring.
Files Learn how to perform file system operations using the workspace object in your scripts.
Fetch Learn how to use fetch and fetchText in scripts to make HTTP requests and handle text responses.
Cache Learn how LLM requests are cached in scripts to optimize performance and how to manage cache settings.
TypeScript Learn how to use TypeScript for better tooling and scalability in your GenAIScript projects.
Web Search Execute web searches with the Bing API using retrieval.webSearch in scripts.
Secrets Learn how to securely access and manage environment secrets in your scripts with env.secrets object.
YAML Learn how to use YAML for data serialization, configuration, and parsing in LLM with defData, YAML class, and JSON schema validation.
CSV Learn how to parse and stringify CSV data using the CSV class in scripting.
INI Learn how to parse and stringify INI files in GenAIScript with the INI class, including methods and usage examples.
XLSX Learn how to parse and stringify Excel XLSX files with ease using our tools.
HTML Learn how to use HTML parsing functions in GenAIScript for effective content manipulation and data extraction.
Choices Specify a list of preferred token choices for a script.
Containers Learn how to use containers for secure and isolated execution of untrusted code with Docker in software development.
Diagrams Create diagrams and charts within markdown using GenAIScript and the mermaid extension for visual representation of data and processes.
Imports Learn how to enable module imports in GenAI scripts by converting them to .mjs format and using static or dynamic imports.
Browser Automation Discover how GenAIScript integrates with Playwright for web scraping and browser automation tasks.
Chat Participants Create multi-turn chats or simulate conversations with multiple chat participants
Concurrency How to run multiple prompts concurrently
GitHub Support for querying GitHub
Import Template Learn how to import prompt templates into GenAIScript using `importTemplate` with support for mustache variable interpolation and file globs.
LogProbs Learn how to use logprobs to diagnose the performance of your scripts
Git Git utilities for repository operations
Prompty Learn about the .prompty file format for parameterized prompts and its integration with GenAIScript for AI scripting.
Tokenizers Tokenizers are used to split text into tokens.
Notebook Explore the features of the Markdown Notebook for authoring documentation with script snippets and inline results.
Response Priming Learn how to prime LLM responses with specific syntax or format using the writeText function in scripts.
AICI Learn how to use Microsoft AICI with GenAIScript to constrain LLM outputs using WASM and JavaScript programs.