Janani Sekar:
Hi everyone, and welcome to video seven. As promised, this will be the module where we finally talk about how to use AI agents, coding agents in particular to build your own custom agents. And we will do, as promised, a more in- depth demo here. All the materials will be shared. Okay, so the thesis of this module is going to be that if we can vibe code and we can turn natural language, whether it's spoken or written language into working code, then we can build agents for tasks that do not already exist. So remember I mentioned earlier, imagine that you want to interact with the Spotify API and get data from Spotify, or you want data from the Bureau of Labor Statistics, or you want data from some other database on the internet. We can instruct a coding agent to take a language model, connect it to these APIs, and build us a custom tool for some repetitive task that we find ourselves doing often.
Typically, anything that is repetitive that we know that we can review and quality control reasonably well is the type of thing that we want to outsource to an agent. So like I said, we're going to go through an example. This example is coded entirely through natural language. It's vibe coded in Google CoLab. So Google Colab is a interactive, collaborative platform. It works on the browser and it is for Python code. Because it's by Google, it comes by default with Gemini integrated, which means that there is a chatbot on the side that you can interact with the entire time that you are programming in Google Collab these days. It is also free. At least there's a pretty generous free tier, so it's a great place to start if you are interested in beginning your vibe coding journey. So this agent that I built for this demo is an economic agent using FRED, which is the St. Louis Federal Reserves Open Access API.
You do have to go in and make an account and obtain an API key, but once you do that, it is pretty straightforward. So let's open up this demo. I wanted to store the conversation that I used to make this demo work, but it seems as if that's been clear. So well, let's run this notebook step by step so that I can show you how this custom agent works. And then at the very end, I'll show you how you can use the embedded coding agent in the notebook to build on what might already be here. So the prompt that I used to ask Gemini to do this was I said, I already went to the Fred website and I got myself an API key. Using this API key, I want to be able to query the Federal Reserve's data, pass in requests to my agent, and have an agent that can go through, access that API and give me the data that I'm looking for.
And I didn't write any of the code that you're seeing here. This was all done by this model. Over here, the model has told us that the reason for this code here is it's going to install some libraries in Python. It's then doing some setup of our API key. I had to put my API key in this secrets section of my notebook that is basically going to obscure the actual letters and numbers of the key itself because it is a sensitive secure access token, but it's going to give my model and this coding session that I'm running access to that login information. The agent then created a function in Python to get data from this API, get a series of information. So a series might be CPI, it could be inflation, it could be any other data that is found in this database. And so we'll run this cell to load that function.
We then need access to a language model. So remember that an AI agent is powered by a language model reasoning engine. Apologies. We got disconnected there for a second, but as I was saying, the core reasoning engine of any agent, including this one, is going to be a language model. And because this is a Google environment with a Google LLM-based coding agent, it has decided that the LLM reasoning engine, the agent is going to be driven, this FRED agent is also going to be driven by Gemini. So the language model that we are going to use for our Fred agent, just as the language model that is being used here in this notebook is going to be Gemini. And so in order to access Gemini in our code, we're going to need another API key because Gemini is also a software application. And to talk to this language model from this programming notebook, we are going to need an API key.
Fortunately, I've also gotten one of those already and stuck it in my notebook secrets. We will have to run this function. This is going to initialize this model fingers crossed that this works. That did not work. All right, let's see why that doesn't exist. I see it's because it's called Google API Key. Let's fix it. Let's give the model access to it and then fix it.
I can't type that for some reason. So let's just make a new one called Google API Key. And we're going to copy paste what's here and put it in here because it's going to be the same. And sorry, friends, I'm going to obscure that from you so that you are not able to get into my Google account. And I'm going to run that again. And now that worked because this notebook has access to my Google API Key. Let's run this. What the coding agent has decided to do here is set the Gemini model inside this reasoning engine to be Gemini 1.5. That is a pretty old version of this model, and that is A- okay. It is going to be good enough for querying the Federal Reserve. Now we're building the agentic logic. So this is where it is defining the ability of the agent to access the Federal Reserve tool.
And so the description of the tool is one that fetches economic data series, and it's going to always get us an economic series with a start date and an end date. It's also got a prompt for getting that series. And so this prompt was not written by me. In this case, it was written by the agent because this all happened automatically and agentically. Okay. So that happened and now this agent does a bunch of things. Notice how it calls the tool, it gets a response, it looks at that response, and then it returns to the user either that the data was successfully returned and it displays it, or it tells the user, "Hey, I ran into one of many errors and unfortunately I was not able to find the data that you were looking for." Let's test out this agent. I did this earlier today and it looks like it worked.
Let's make sure it works again. I said, "What is US GDP since 2010?" And that is a 404 error because Gemini 1.5 is no longer available. So let's see if we can find out if there's another model that is available instead. Maybe we can try Gemini 2.5 flash that'll work instead.
This is a good lesson in vibe debugging. That didn't work either. Okay, so let's get the model to maybe agentically explain to us what's going on. If it takes a really long time to think, I might cut the video here and then restart when it's done thinking. So just a heads-up that that might be happening in a few seconds. Okay, so coming back, you can see in this window that the model finished thinking, and it said that Gemini 2.5 flash latest is not a valid model name either. It's using Gemini 1.5 flash, which apparently should resolve the issue. Let's see if that works. We can hit this accept and run button. That did not work either. So let's tell the model what to do.
I'm actually just going to give it the direct error message because it tells us what to do and it says call list models to see the list of available models. I don't know how to call list models because I don't exactly know how that function works. I don't know if it takes inputs. I don't know what its outputs are. So I'm going to let the coding agent try and address this for me. Once again, I might cut the video while it's thinking. Just know that that is coming up. As I said, I wasn't sure how to use that function earlier, but it seems like my coding agent has experience doing this, so let's run this to see if it can. Perfect. Okay. So now we've got a list of all of the models that we can use. Sure enough, 1.5 is not one of them, but 2.5 flash is.
Had I tried that earlier, but maybe I had latest at the end, so let's see if this works this way.
Perfect. And that looks like it worked. It fetched data successfully. There is a start date, but there's no end date because we are going since 2010. So up to now means that there is no end date, and that looks like a series ending with 2025 July as the last value. This is the cell where I listed out the models. I'm not going to delete that. It's kind of out of place right now, but we'll leave it in for reference. And we can also test out unemployment. Similarly, see that we are passing in in natural language in just plain English the data that we're looking for, our agent is able to parse this and then figure out what column or what economic series to query from the Federal Reserve. So I think this is a pretty cool thing that we don't have to know that rate is how the Federal Reserve stores unemployment.
We can just say, "Show me unemployment," and the agent is going to be able to translate that into the data that it has to fetch. We can do CPI similarly. This is going to work well for us. And then finally, I also asked Gemini to do this earlier today, so I told this to do it. I told it to do this in ... So I also told Gemini to do this earlier today, which was to take the data that we've queried, so to get GDP, to get unemployment, to get CPI, and then to make me some visualizations. So this is a lot of code. I did not write any of it. It was just a prompt that I asked the model, and it wrote me some code to visualize these series. Let's see what that looks like. And so there's unemployment, there's CPI, there is GDP.
We've got those COVID spikes. Everything looks pretty much like we'd expected to, and it was not all that difficult to go from our API key to our agentic interface, to even getting visuals of these economic variables. So thank you all for watching this demo. Hopefully this agentic interface and this process makes a little bit more sense now that you've seen a concrete example of it. Hopefully some of that live debugging, which I didn't intend for, was actually additive and interesting to see. And I will see you all in the last video, which is the conclusion, and I will do my best to make sure that we make this material and this notebook available to you all also.