Getting Started
GenAIScript is a scripting language that integrates LLMs into the scripting process using a simplified JavaScript syntax. It allows users to create, debug, and automate LLM-based scripts.
GenAIScript brings the flexibility of JavaScript with the convinience of built-in output parsing to streamline the creation of LLM-based software solutions.
the script
The following script takes a file with text content (.txt, .pdf, .docx) as input and saves a summary of the file in another file.
GenAIScript will execute summarize.genai.js
and generate the user message that will be sent to the LLM chat.
It also populates the env.files
variable with the files selected in the context (from a user UI interaction or CLI arguments).
System scripts
GenAIScript also automatically selects system scripts to support file generation and other features. Since
we’re using files in this script, it will run the system.files
script which teaches the LLM how to format files
in a structured format.
And the resulting system prompt.
LLM invocation
All the generate prompts are formatted and sent to the LLM for processing. Typically, using the OpenAI Chat API (or compatible), this would be a JSON object with an array of messages.
Output parsing
The LLM responds with a text which can be parsed for various micro-formats, like markdown code fences, files or annotations.
GenAIScript automatically makes sense of the output and exposes it through a Refactoring Preview or directly saved to the file system.
Of course, things can get more complex - with functions, schemas, … -, but this is the basic flow of a GenAIScript script.
Next steps
Let’s start by installing the extension in Visual Studio Code.