// automatically convert to text def("PDF", env.files, { endsWith: ".pdf" }) // or parse and process const { pages } = await parsers.PDF(env.files[0])
def("DATA", env.files, { endsWith: ".csv", // take top 100 rows sliceHead: 100, }) // or parse to JavaScript object array const rows = await parsers.CSV(env.files[0])
const { files } = await workspace.grep(/[a-z][a-z0-9]+/, { globs: "*.md" })
so it seems to me these things could totally be so useful that you might use these and never care about the AI parts, at any rate I think I have to devote next week to this, as soon as the project I am on right now is shipped.
demo: https://youtu.be/XlO4KhIGd0A https://youtu.be/cs5cbxDClbM
""" Be ambitious about what you want your script to do
Remember, LLMs in GenAIScript can do things that no other software has been able to do. Think outside the box in the ways that you use it. LLMs can critically review a document, write poetry, and analyze images, just as a starting point. They have built-in expertise on many different human endeavors, math, history, etc. and their knowledge can be easily extended by adding more context to the script input (see next point). """
This above comes under the "Best Practices" page.. why?
> Programmatically assemble prompts for LLMs using JavaScript.
> $`Analyze ${env.files} and report errors. Use gitmojis.`
This is kinda misleading and confusing as a lead. I could literally say: > Programmatically assemble prompts for LLMs using strings!
> ... amazing!
I like that they've provided ways to define schemas and standardized function-calling/tools, plus CLI helpers. But I find the page quite overwhelming hype-y. This could be reduced to a 30 line readme with much clearer examples. When did shipping JS libs as product-y websites become a thing?I'm going to be honest, I'm still confused about what I'm looking at.
I tried listening to the NotebookLLM podcast you've embedded, which makes it sound like this is primarily directed at non-programmers (people who want to "run for the hills" when they hear the name GitHub). But then your README looks more targeted at web programmers who want to write TypeScript-like code.
When I get to the rest of the README, I'm unclear what "JavaScript-ish environment" means. Does that mean this is something like AssemblyScript, a subset of TypeScript? If so, why did you decide to do a subset instead of a library?
Addendum:
As I'm going over the README again, trying desperately to make sense of it, I found this:
> This readme is maintained by the readme-updater script.
At least I now understand my confusion.
In one evening I whipped up a lib for talking to ollama, usings agents, tool use, sandboxed code execution etc. and that was doing it the hardish way, from scratch.
This seems like a decent collection of tools but anyone able to use this could already do the same things with normal JS with not a lot of effort.
[0] "This readme is maintained by the readme-updater script." https://github.com/microsoft/genaiscript
"Imagine the following code belongs to a known language and execute it"?
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.
which ruins my hope that it was a JS library I could drop into other things and work together with other JS libraries. Although I guess can implement some sort of bridge to it to allow that, why not a full js library not sure.
on edit: huh, maybe available js library https://news.ycombinator.com/item?id=42002316
There's nothing about improving their ability to effectively process this data and draw actionable conclusions from it that makes them more likely to stop.
I'm wondering if the same functionality would be available as an actual JavaScript library, or whether there is something special (other than syntactic sugar) that requires a different file type?
Note that the container link on the homepage to https://microsoft.github.io/genaiscript/referenc/scripts/con... seems to be broken.
Edit: Okay, taking a deeper look - this seems to be a separate runtime on top of node - "$" seems to be global and files are defined as .genai.mjs and run through VSCode. I see that there's a way to run via CLI as well: `npx genaiscript run proofreader path/to/files*.md`, but I wonder what the rationale around these design decisions are. It seems like it's tying these files to a different runtime - can I use them directly in Node or Bun as part of an API? Something like "import {templateStr as $, def} from 'genaiscript'", then use it normally in Node?
Also had some more time to look at the code, seems like the CLI is using https://github.com/microsoft/genaiscript/blob/main/packages/... to execute scripts which uses promptrunner in core https://github.com/microsoft/genaiscript/blob/main/packages/... - it looks like it's not trivial to use directly from JS or decouple the runtime? Unless that's on the roadmap somewhere to be able to call the scripts in the same process as a Node app.
That’s my best guess.
$ npx genaiscript script create proofreader
Need to install the following packages:
[email protected]
Ok to proceed? (y)
file /Users/me/src/learn/genaiscript/proofreader/genaisrc/proofreader.genai.mjs already exists
Error: file /Users/me/src/learn/genaiscript/proofreader/genaisrc/proofreader.genai.mjs already exists
at copyPrompt (/Users/me/.npm/_npx/3f5b5bbcce7f85b9/node_modules/genaiscript/built/genaiscript.cjs:96237:35)
at async _Command.createScript2 (/Users/me/.npm/_npx/3f5b5bbcce7f85b9/node_modules/genaiscript/built/genaiscript.cjs:96327:15)
npx genaiscript script create proofreader2
For example, I may be building a text game, and I may have to get rules, state, character specs, etc. Then I may have to load these things into a document as part of a prompt for the LLM to consume.
Simple, as others mentioned. But still nice to have something to reach for rather than building this myself.
Edit: And thanks! This is timely.
I have no idea what this does. I think maybe if the examples included the output then it might be helpful?
$`Analyze ${env.files} and report errors. Use gitmojis.`
If we knew what env.files is and what it output it would help. Does it doing some magic that looks in the file system for the files listed as env.files, combines them and passes them to the LLM? Or does the LLM write code to get the files? Or something else.What does "Analyze" mean? I assume because of the mention of gitmojis they are code files, but maybe that assumption is wrong and it is expecting spreadsheets and can find errors in formulas? I don't know..
Edit: https://microsoft.github.io/genaiscript/blog/automatic-web-p... isn't perfect but a little bit more useful.
I started messing with this yesterday and was able to get a fully functional refactor engine (complete with code review, running tests, building TS, etc.) going in less than a day.
We were looking for a tool to bake into our developer tooling that supports things like this, and this GenAIScript project has been perfect so far. Definitely doesn't seem quite ready to embed this into customer-facing stuff, but I'm finding it tremendously helpful for LLM-powered tooling!
Many thanks, pelikhan, for publishing this!