DEV Community

Cover image for AI for creating AI part 1/2.
MindsDB Team for MindsDB

Posted on • Edited on • Originally published at mindsdb.com

AI for creating AI part 1/2.

Written by Jorge Torres, CEO @ MindsDB

Remember when JavaScript frameworks multiplied faster than rabbits on energy drinks? Every developer and their pet hamster could whip one up between bites of cold pizza and sips of lukewarm beer. Well, history's greatest hits are playing on repeat - except now it's AI agent frameworks breeding like conspiracy theories at a flat earth convention. At this rate, some milk in my fridge might outlive half the frameworks announced this week.

There was one great blog post from December 24 about Building effective agents + a video summary by the legend Matthew Berman (here). Where simplicity is the aim.

TLDR; Current AI Agent frameworks evolved to be about as streamlined as a drunk octopus trying to put on a sweater.

I immediately wondered, can AI help itself make itself simpler?

So there I was, peak productivity: AI doing the heavy lifting (me being boss) while I fell down a YouTube rabbit hole of cats fighting cucumbers. Thinking, If team AI+yours truly can conjure up pristine AI Agents from scratch in the time it takes most people to decide which oat milk belongs in their coffee, you better believe anyone can. I am convinced we're about to witness AI apps pop-up faster than startup founders' buzzwords during funding season. The mobile app explosion of 2008? That's going to look like dial-up internet compared to the AI tsunami heading our way. ๐ŸŒŠ๐Ÿค–

How-to build AI from scratch tutorial (using AI)

While you sip that macchiato, we will try to go over how anyone can use AI to build AI Agents (clean).... Hold your pants because we will get a bit technical. But just like me, you won't need to know how to code a thing.

Step 1: Building a foundation.

I want my AI Agents writing to be as straightforward as writing Python code for pre-schoolers - not an IQ test or something that reads like IKEA instructions translated through seven languages and back.- And, I do feel like current Agent stuff for developers out there is way more complicated than it probably needs to be. IMHO the simpler it is, the simpler it will also be for AI to build atop of it's own building blocks.

So, I'm gonna do what every person would do now days -nothing much- and whisper sweet nothings to Cursor (a badass AI code editor, for those of you fixing the ridges of a fancy Tin foil hat while hiding in that bunker). Anyway, I am going to command cursor until it builds me a python Agent library so slim, it would make a supermodel jealous. Just enough code to turn that API into my personal coding daddy. Because sometimes, less code is more - like my bank account after buying shares at NVIDIA a few years ago (I wish).

NOTE: I tried it, I said to it to him: "Cursor give me a badass wrapper for OpenAI SDK, given this blog post. ..." And it did something, but not what I wanted. so, back to the idea board, because, I think the point in this post is to show that anyone (yes also your mom) could in fact make these AI babies do exactly what you dream, faster than you can say "unicorn".

GAME PLAN UPDATE: Since one-line prompts are not going to cut it, I'm going to write the world's most passive-aggressive README.md file instead.

For the uninitiated, a README.md is like that note your roommate
leaves on the fridge explaining why there's a flamingo
in the bathtub and how to feed it , but in the code of
an Open Source project.
Enter fullscreen mode Exit fullscreen mode

Picture this: a technical document that's one part manifesto, two parts and a dash of that special sauce that makes Stack Overflow moderators blush. - It'll be my wishlist to the AI gods, demanding a framework so lightweight that it makes a photon feel self-conscious about its mass.

I thus, faced existential questions, like: What is that I really want, and nothing better than stealing ideas when lost, so I went back to the Anthropic blog Building effective agents, and this what's in there:

Workflows

MY THOUGHTS, If the Anthropicos, if they were a person, they'd be that friend who color-codes their sock drawer and has a spreadsheet for tracking their spreadsheets.

Me? Back to the basics baby - if you follow from here on, it's will feel like having a Swiss Army knife in a world where everyone else is building nuclear-powered can openers.

Let's cover part by part, and translate that to things we can code (when I say we, I mean that AI can code).

Gates

They talk about gates, to control the logic flow, seems sophisticated:

Anthropic Gates

But the truth is that in every single programming language, gates are just IF/ELSE statements. Really not much more than that.

if llm:"Is this real life?":
    -- do something
else:
    -- do something else
Enter fullscreen mode Exit fullscreen mode

Routers

They cover routers too, looks like this:

Anthropic Routers

OK, these are fancier IF/ELSE gates, but hold my beer - a hundred years ago, someone invented switch/case statements (match/case in Python).

switch llm:"where do we go from here?":
    case 'option1':
        -- do something
    case 'option2':
        -- do a different something
    case 'other':
        -- do something even differenter
Enter fullscreen mode Exit fullscreen mode

Parallelization

Anthropics parallelization

Oh, you want parallel processing in Python? That's like asking "should I reinvent the wheel?" while riding a Tesla. We've got ThreadPoolExecutor (sounds like a rejected Terminator movie) and Celery (because nothing says "distributed computing" like vegetables) doing the heavy lifting since before ChatGPT was a twinkle in Sam Altman's eye. But sure, go ahead, build your own - I'll wait here until the heat death of the universe.

Agents

Straight from the AI prophet's mouth: "Agents can handle sophisticated tasks, but their implementation is often straightforward. They are typically just LLMs using tools based on environmental feedback in a loop."

Translation: It's basically a Python script doing the hokey pokey with an API - you put the prompt in, you get the output out, you do the while loop and shake it all about. And here we were thinking we needed quantum computing and a PhD in rocket surgery! Thank goodness Guido van Rossum had that wild weekend in '89 and blessed us with for loops and functions. Without those brand new Python features, we'd be building our AI agents with stone tablets and carrier pigeons.

README.md

So I essentially copied the things I just wrote and told ChatGPT to give me a README.md, and then I did some cleaning, and ended up with this README.md.

Cursor for the win

Then I slid into Cursor's DMs like a tinder-bot, "Hey baby, how about you cook me up a Jupyter notebook that makes this flat-ai framework dance like it's auditioning for AI's Got Talent?" _Because nothing says "I'm a serious developer" like sweet-talking your IDE into doing your homework. And let me tell you, Cursor played hard to get for about 0.3 seconds before it said _I do.

tutorial.ipynb

And hot damn, it worked like a charm! Behold the magic here. At this point, I was feeling like Mr. Dr. Frankenstein after his monster just aced the MCAT - time to crank this baby up to 11.

flat-ai library

For the grand finale, I pinky-double-dared Cursor to conjure up a Jupyter notebook showcasing this flat-ai framework. Not only did this absolute madlad materialize an entire PyPI-ready library faster than you can say "let me grab a bevg while I wait."

And holy quantum Batman... The thing ACTUALLY WORKS! ๐Ÿš€ We've officially reached peak dev laziness, and it's absolutely beautiful. wipes tear with requirements.txt

check it out here.

Image description

Top comments (0)