Nice, same – LET’S FIX THAT.
GPT-4 and all LLMs have one major flaw: The Context Window. If you’ve written prompts and have tried to insert tons of data into a single prompt you’ve likely experienced a TOKEN EXPLOSION. Our Postgres AI data analytics is running into this very issue. We’ve been building and testing with only 2 tables when in reality, we need to operate on potentially hundreds of postgres tables and millions of rows. In this video, we directly address that issue with two primary techniques.
First, we utilize vector embeddings to run a similarity search across all of our table’s SQL creation statements against our natural language query. Next we utilize simple string matching that gets the job done 100x better than vector embeddings at the cost of being a bit more verbose in our prompt. If you can solve the problem with a simple solution, start there. This enables us to load only tables relevant to our query into our initial prompt that our multi-agent system takes, generates SQL for, and then obtains the response. It’s not all good news though.
In order to allow potentially millions of rows process through our postgres ai agent system, we have to let go of our AutoGen multi-agent data visualization team. After we add token and price estimation into our orchestrator class we learn that our data viz team is just too expensive to keep on the team in our current inflationary market. We have to let them go and tighten up our multi-agent team. It seems ridiculous but one day we may be making judgement calls on which ai agents we want to keep on our team and which ones we need to let go. This is the beginning of agentic software engineering.
👍 THE CODEBASE
https://github.com/disler/multi-agent-postgres-data-analytics/tree/v4-autogen-token-tactics-firing-ai-agents
✅ Watch Part Three – Make AutoGen Consistent
https://youtu.be/4o8tymMQ5GM
🤖💻 AI Engineering Resources
Microsoft’s Autogen: https://microsoft.github.io/autogen/
Free Postgres Hosting With Neon: https://neon.tech/
Bert Word Embeddings: https://is-rajapaksha.medium.com/bert-word-embeddings-deep-dive-32f6214f02bf
🤖 ZERO Touch coding with AIDER? YUP
https://youtu.be/MPYFPvxfGZs
📘 Chapters
00:00 Push into a new field of agentic engineering
00:50 Our Postgres tool has one MAJOR problem
02:00 Let’s Review Our Mult-Agent Tool
03:50 I’ve been deceptive – here’s why
04:50 CLEAN Refactor
07:05 Now We’ll Light A Dollar On Fire
08:28 Vector Embeddings Module
12:55 Embeddings don’t always work – try this
16:55 Keep track of OpenAI GPT-4 Costs
20:15 Bad News For Our AI Agent Data Viz Team
22:00 Our new trimmed down multi-agent team
26:10 Keep stacking your AGENTIC building blocks
26:50 What’s next? API, UI, More Agents, More Conversation Flows
28:35 Let’s discuss top comments
🐛 tags
#sql #agentic #promptengineering
Add comment