Generative AI Scripting
197 points by baublet 8 days ago | 47 comments
  • bryanrasmussen 8 days ago |
    there are lots of useful parts here doesn't seem like it is Gen.AI but some other provided tool

    // 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.

    • yjftsjthsd-h 7 days ago |
      Sorta-side note but for readability: To format code on HN, indent with 2 spaces.
  • bryanrasmussen 8 days ago |
    question - is workspace.grep using JS regex or is it using actual grep? Like on Windows part of this would be depending on the Linux for Windows tools?
  • Edmond 8 days ago |
    For folks who would prefer a more "full bodied" experience, we offer a UI configuration based alternative approach that supports JavaScript and Groovy, including an IDE environment integration.

    demo: https://youtu.be/XlO4KhIGd0A https://youtu.be/cs5cbxDClbM

  • nidnogg 7 days ago |
    This might be a simple question to answer but I couldn't find it from skimming these docs: what LLMs can this hook to? Do I plug an actual API key like 90% of tools? Where's the AI compute part coming from?
  • layoric 7 days ago |
    This looks like a useful tool but.. please review your generated docs for utility.

    """ 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?

    • owenpalmer 7 days ago |
      This is hilarious!
    • LunaSea 7 days ago |
      Might have been generated by an LLM ironically.
  • mmaunder 7 days ago |
    Seeing that human written JSON structure convert to a more human readable few shot example in the code makes this feel like a step backward. Easier for the human to write the human readable example. Yes it’s doing file access and may fulfill other programmatic tasks that aren’t just prompting, but retrieving files quickly goes to RAG or similar, and the logic gets so complex an actual programming language begins to make more sense.
  • padolsey 7 days ago |

      > 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?
    • pelikhan 7 days ago |
      Hi GenAIScript dev here, you'll find the readme at https://github.com/microsoft/genaiscript. Thanks for your feedback!
      • lolinder 7 days ago |
        Thanks for dropping by!

        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.

      • trenchgun 7 days ago |
        Can you clarify, are you also an LLM, or are you a human dev? > This readme is maintained by the readme-updater script.
    • grahamj 7 days ago |
      Agree. Using LLMs from code is already so easy I don't see why a developer would need something like this.

      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.

    • lolinder 7 days ago |
      Given that their README is openly being maintained by an LLM [0], I wouldn't be surprised if most of the site's copy is as well. It would go a long way towards explaining why it feels even more bloated and incoherent than usual.

      [0] "This readme is maintained by the readme-updater script." https://github.com/microsoft/genaiscript

      • mentalically 7 days ago |
        I wonder how long it will go before it devolves into complete incoherence. It already seems incoherent so probably in a few updates it will be completely unreadable.
        • namaria 6 days ago |
          Kafka would be proud. We're gone from the dream of a semantic web to industrial grade non-sense spreading automatically.
          • mentalically 6 days ago |
            It does seem like everything is heading in that direction.
  • 101008 7 days ago |
    I don't get it from the landing. Is this like a fake code language that a LLM can interpret? Is the syntax invented on the go? Like if I ask GPT:

    "Imagine the following code belongs to a known language and execute it"?

    • bryanrasmussen 7 days ago |
      from the getting started https://microsoft.github.io/genaiscript/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.

      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

  • beefnugs 7 days ago |
    ok Microsoft, so you are trying to make something useful out of LLMs. But now that you have one hell of a reputation to overcome, the questions are: Is this happening on device? Without sending anything to the internet? And is it going to be REALLY FUCKING CLEAR when you change that in the future? with the option of FUCK NO instead of "maybe later"?
    • heroprotagonist 7 days ago |
      There are absolutely zero indicators that Microsoft will ever STOP being privacy-invasive.

      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.

    • pelikhan 7 days ago |
      GenAIScript does not collect any data/usage analytics. The LLM query is sent to the provider you configured. Hope this helps answer your question?
  • skybrian 7 days ago |
    At first glance, it looks like this is almost JavaScript (or TypeScript), but with imports removed / implied. (Sort of like Arduino is almost C++.)

    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?

    • pelikhan 7 days ago |
      GenAIScript here. Yes it could be available as a library to fit but it'll require a bit of refactoring on our part.
      • shmatt 7 days ago |
        Just throw it into o1
  • Flux159 7 days ago |
    This seems like it can be super useful - lot to go over but want to focus on running commands in containers. Having a clean and elegant way of executing LLM commands in a containerized environment is definitely better than running on a single VM/machine. I do wonder how something like this would run in a containerized application though - can you define the "host" to be a kubernetes control plane?

    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?

    • pelikhan 7 days ago |
      One of the early ideas was to make the scripting syntax as lightweight as possible. Thus not requiring to install or import anythying to start writing a prompt (the project evolved). Definitely inspired from google/zx.
  • bogrollben 7 days ago |
    Could someone please explain what I'm looking at here? Am I the only one mystified?
    • mentalically 7 days ago |
      It was probably generated with an LLM and as far as I can tell it does seem like complete nonsense.
    • bloomingkales 7 days ago |
      I don’t think this is for humans to ever write. It’s mostly readable code for AI to generate, Lego blocks to achieve a task.

      That’s my best guess.

  • johnnylambada 7 days ago |
    Going through getting started on the command line fails:

      $ 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)
    • pelikhan 7 days ago |
      looks like a silly bug on our side. this little helper is just supposed to create an empty file for you. what happens on ?

        npx genaiscript script create proofreader2
      • johnnylambada 7 days ago |
        same
      • johnnylambada 7 days ago |
        I'm on macos 14.5
      • johnnylambada 6 days ago |
        [email protected] fixed it for me -- thanks!
  • chopete3 7 days ago |
    Just when the managers thought they could cut back on developers - they got their Trojan horse in to be relevant in the LLM game.
  • gexla 7 days ago |
    This seems like an equivalent to Mustache or Handlebars except for programmatically building prompts rather than HTML?

    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.

  • nl 7 days ago |
    I work on building "AI" systems daily and a large part of it is assembling and managing large prompts.

    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.

  • baublet 7 days ago |
    Posted this because I didn't see it, just now getting back (toddler).

    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!

  • benzorn 7 days ago |
    Thanks for the input on the GenAIScript landing page and README repo file. We've updated the description and hopefully this makes it clearer what it is and why it is useful.
  • benzorn 6 days ago |
    We really appreciate input helping us both explain what GenAIScript is and how to use it. Please keep it coming! We've updated the Getting Started page (https://microsoft.github.io/genaiscript/getting-started/) to help visitors understand exactly what is in our scripts and how we execute them.