Recipe for Instant Homemade AI Agents With Azure OpenAI GPT-4o Using .NET
John Maeda
AI @ MSFT / Laws of Simplicity + How To Speak Machine / LinkedIn Top US Influencer
This is a step-by-step tutorial for using Azure OpenAI Assistants for making a quick and delicious agent capable of RAG (Retrieval Augmented Generation) that you can interact with via simple .NET code. If you prefer watching video content just skip to the end of this post!
Start with a hub and a project
First you want to be in your "All hubs" in Azure AI Studio before you get started.
Click on the name of your Hub to activate it. Look at the tippy top and you know that you're in All hubs and your particular Hub has been activated. Next, click on "All projects"
Look at the tippy top again and you can see you're in the subroute of "All hubs > your hub > All projects." Go ahead and make a "New project." If you don't, the system won't work in an optimal way so just come along with me on this journey ;-).
You can go ahead and create a project. This can take roughly a minute.
Okay, you're in good shape now because:
Time to make an Azure OpenAI Assistant in the UI
Now let's go use the Azure OpenAI Assistants API route in Azure AI Studio. It's going to be cool!
You should see the Assistants Playground come up. And be sure to follow this sequence:
LLMs will by themselves "make stuff up" unless you ground them in information that matters to you. There's an easy way to do a so-called "RAG" (Retrieval Augmented Generation) by clicking on the little "Tools" tab and adding files to the "File search" feature.
And then a wickedly complex screen pops up like the following. Ignore most of what you see and pay attention to the lower left button that reads "Upload local files" and select a file that's supported to upload it. And then after your file has uploaded, be sure to press "Attach" so that the file gets associated with your assistant named "Assistant671."
You should see the good news after hitting "Attach" like so:
Assuming you have turned on "File search" you can ask any question about the document you've uploaded. I uploaded a fictional travel itinerary and am asking Assistant671 to use the file I've uploaded as the grounding for a response.
Pretty cool, huh? Now let's do that same thing in code instead. It'll feel a lot easier :-).
Creating an Azure OpenAI Assistant API agent with file upload in code
Visit this easy-peasy repo to get going in .NET by "edandersen" on GitHub.
Clone the repo and all you need do is add your Azure OpenAI "endpoint" and "key" in the Program.cs file:
Where do you get that info in Azure AI Studio? Well, do you remember the "Assistants playground" where you were trying out Assistants API? Click on the "</> View Code" button.
And you'll see some code you could include instead of the GitHub repo I've recommended above. But for now, just grab the Endpoint and API Key.
With these two pieces of information added to the Program.cs file, when you do a "dotnet run <filename>" you will be able to upload a file easily.
And the right things happen. Yaaaay!
Take the next step
Are you intrigued? Then I suggest you take the next step and try out multi-agent systems that run on top of Azure OpenAI Assistants API as demonstrated by AI Chef Marco Casalaina on the Cozy AI Kitchen show:
Or watch how agents are reshaping the future of UX with Kwame Nyanning, the world's expert on "Agentic UX":
AI Educator | Learn AI Easily With Your Friendly Guide | Built a 100K+ AI Community for AI Enthusiasts ( AI | ChatGPT | Tech | Career Coach | Marketing Pro)
2 个月Cooking up AI agents like a pro! This guide is the culinary masterclass for AI enthusiasts. Can't wait to see the innovative dishes that come out of this! John Maeda
Professional UI/UX Designer, Brand consulting & Creative business intelligence
2 个月Ok but how can you measure the final product to know how reliable it is?
Founder of SmythOS.com | AI Multi-Agent Orchestration ??
2 个月Intriguing AI kitchen setup. Seems like a tasty way to cook up some innovative AI solutions. Let's dive in and explore this recipe.
Helping you discover Best AI tools | Building AI Tools Radar
2 个月Wow, John Maeda! This AI 'kitchen' guide is fantastic. Love how you break it down like a cooking show. Ready to whip up some AI agents!