A long standing feature request has been to run GenAIScript programmatically from other scripts. We are happy to announce that we have released a Node.JS API for GenAIScript. This API allows you to call GenAIScript from other TypeScript scripts (v1.83+).
The run API is meant to mimic the behavior of the GenAIScript CLI. It takes the same arguments as the CLI and returns the same results. This allows you to call GenAIScript from other TypeScript scripts.
The result object contains the full list of messages, and additional parsed information like modified files, diagnostics and so forth.
Don’t mess with my process
On the caller side, the run implementation is a dependency free, side effect free function. It spawns a worker thread where GenAIScript does the work.
No global added
No package loaded
A few hunbred b of memory used
Help us improve it!
Obvisouly this is a first draft and we could do a better job at providing callbacks for progress. Send us your feedback!
Have you ever found yourself in a situation where you need to search through multiple files in your project, find a specific pattern, and then apply a transformation to it? It can be a tedious task, but fear not! In this blog post, I’ll walk you through a GenAIScript that does just that, automating the process and saving you time. 🕒💡
For example, when GenAIScript added the ability to use a string command string in
the exec command, we needed to convert all script using
In this blog post, we’ll dive into a practical example showcasing how to leverage GenAIScript for automatic web page content analysis. GenAIScript uses the playwright browser automation library which allows to load, interact and inspect web pages.
Step-by-Step Explanation of the Code
The following snippet provides a concise and effective way to analyze a web page’s content using GenAIScript:
Let’s break down what each line of this script does:
1. Navigating to a Web Page
This line automatically navigates to the specified URL (https://example.com). The host.browse function is a powerful feature of GenAIScript that initializes a browser session and returns a page object for further interactions.
2. Taking a Screenshot
Here, the script captures a screenshot of the current view of the page. This is particularly useful for archiving or visual analysis.
3. Defining Images for Analysis
After capturing the screenshot, this line registers the image for further analysis. defImages is a function that makes the screenshot available to subsequent analytical or AI-driven functions in the script.
4. Extracting Text Content
This command extracts all text content from the page, which can be invaluable for content audits or textual analysis.
5. Storing Text for Further Use
The extracted text is then stored under the identifier PAGE_TEXT, allowing it to be referenced in later parts of the script or for documentation purposes.
6. Analyzing the Content
Finally, this line represents a call to an AI or script-defined function that analyzes the captured content and provides insights. This is where the real power of automation and AI integration into GenAIScript shines, enabling detailed analysis without manual intervention.
Conclusion
With a simple yet powerful script like the one discussed, GenAIScript makes it feasible to automate the process of web page content analysis. Whether you’re conducting competitive analysis, performing content audits, or simply archiving web pages, GenAIScript offers a scalable and efficient solution.
Bringing a new version of a product into the world is always exciting! But alongside the thrill comes the duty of informing users about what’s changed. That’s where generating crisp, engaging release notes comes into play. ✨
Today, we’re going to explore a script that automates the creation of release notes for GenAI. The script is part of the GenAIScript ecosystem, which harnesses the power of AI to bring efficiency to software development processes. 🚀
If you want to dive straight into the script, it’s available on GitHub right here.
The script is a .genai.mjs file, meaning it’s a JavaScript file designed to be run with the GenAIScript CLI. The code within orchestrates the creation of release notes by leveraging Git commands and GenAI’s capabilities.
Let’s walk through the script, step by step:
Step 1: Initializing the Script
The script starts by initializing with a script function. We’re setting it up to access system commands and specifying the AI model to use. The temperature controls the creativity of the AI, with 0.5 being a balanced choice.
Step 2: Setting the Product Name
Here, we’re using an environment variable to set the product name, defaulting to “GenAIScript” if it’s not provided.
Step 3: Finding the Previous Tag
We are reading the current version from package.json and using Git to find the previous release tag in the repository.
Step 4: Gathering Commits
This block runs a Git command to retrieve the list of commits that will be included in the release notes, excluding any with ‘skip ci’ in the message.
Step 5: Obtaining the Diff
Next, we get the diff of changes since the last release, excluding certain files and directories that aren’t relevant to the user-facing release notes.
Step 6: Defining Placeholders
We define two placeholders, COMMITS and DIFF, which will be used to reference the commits and diff within the prompt.
Step 7: Writing the Prompt
Finally, the script ends with a prompt that instructs GenAI to generate the release notes. It details the task, guidelines for what to include, and the style to adhere to.
How to Run the Script with Genaiscript CLI
Once you’ve crafted your script, running it is a breeze with the Genaiscript CLI. If you haven’t installed the CLI yet, you can find the instructions here.
To execute the script, navigate to your project’s root directory in the terminal and run:
Remember, we use the script filename without the .genai.mjs extension when invoking it with the CLI.
And that’s it! The GenAIScript CLI will take care of the rest, combining the power of AI with your code to generate those sleek release notes for your project’s next big launch. 🌟