Skip to content

Blog

Make it better!

GenAIScript comes with a helper that tells the LLM to “make it better”. It’s a surprising way to improve your code by repeating a set of instructions multiple times.

Code Explanation

Let’s walk through the script line by line:

import { makeItBetter } from "genaiscript/runtime"

This line imports the makeItBetter function from the GenAIScript runtime. This function is used to improve code by repeating a set of instructions multiple times.

def("CODE", env.files)

This line defines a constant named “CODE” that represents the files in the environment. It essentially sets up the context for the code that needs improvement.

$`Analyze and improve the code.`

This line is a prompt for the AI model. It instructs the system to analyze and enhance the code. The $ is used to denote that this is a special instruction, not a regular code command.

// tell the LLM to 'make it better' 2 times

This comment explains the upcoming line of code, making it clear that the makeItBetter function will be called twice.

makeItBetter({ repeat: 2 })

This line calls the makeItBetter function with an option to repeat the improvement process twice. It triggers the enhancement process.

How to Run the Script

To run this script using the GenAIScript CLI, you need to execute the following command in your terminal:

Terminal window
genaiscript run makeitbetter

For detailed instructions on installing and setting up the GenAIScript CLI, check out the GenAIScript documentation.

By following these simple steps, you can harness AI to make your code better with ease! 🌟

Revamping the views...

In the past, our Visual Studio Code visualization has relied on the built-in Markdown preview feature. It’s been working great but sometimes it’s not enough. We wanted to provide a more interactive experience for our users. So we decided to build a custom webview for GenAIScript.

Rebuilding the view also gives us more control on supporting the rendering of various markdown subformats like mermaid diagrams, annotations, math, …

A screenshot of the GenAIScript view.

Accessing the view outside of Visual Studio Code

As a result of this change, you can now access the GenAIScript view outside of Visual Studio Code. This means you can now run your scripts in a browser or any other webview-capable application.

Launch the serve command from the cli to start the server and follow the instructions to open the view in your browser.

Terminal window
genaiscript serve

Video Introduction

The very first tutorial video on GenAIScript is out on YouTube.

It took a while to get back the setup but we are now ready to start the series of tutorials on GenAIScript. Use discussions if you want to suggest a topic for the next video.

Play

Let there be videos!

The latest release includes support for including videos and audio transcripts in your scripts.

const frames = await ffmpeg.extractFrames("demo.mp4", { transcription: true })
def("DEMO", frames)
$`Describe what happens in the <DEMO>.`

Say you want to analyze a video file. For most LLMs that support images, you would have to extract screenshots at particular timestamps then send them as a sequence of images. Choosing those timestamp could be a challenge since you will run out of context window. GenAIScript provides a helpers to solve this tedious tasks around video analysis using LLMs.

tools and agents

We also provides wrap the new functionalities in tools and agents so you can use them in your scripts.

For example, to include the frame extraction tool so that the LLM is able to call it, you can use the following snippet:

script({
tools: "video_extract_frames",
})

Or just let the agent work on the video for you.

script({
tools: "agent_video",
})

Playground, o1 and DeepSeek

The newly 2025 release brings a number of new features and support for new models.

Playground

The Playground is a self-hosted web application that allows you to run GenAIScript scripts from a friendly user interface. It sits between the GenAIScript CLI and the GenAIScript Visual Studio Code integration.

A screenshot of the playground.

o1

GenAIScript supports the various flavors of the OpenAI o1 models (mini, preview, …). It also adds support for tools.

o1 is also available on GitHub Models!

script({ model: "github:o1" })
$`Prove that the sum of the angles of a triangle is 180 degrees.`

DeepSeek

GenAIScript supports DeepSeek V3 through their OpenAI API.

script({ model: "deepseek:deepseek-chat" })
$`Prove that the sum of the angles of a triangle is 180 degrees.`