LongCut logo

How to use Kaggle Notebooks

By Kaggle

Summary

Topics Covered

  • Copy Notebooks for Hands-On Agent Building
  • Run Code Cells Top-to-Bottom Order
  • Never Paste API Keys in Notebooks
  • Add API Key as Kaggle Secret

Full Transcript

Welcome to the 5-day AI agents intensive course with Google. This video is your beginner guide to running all of our code labs which are hosted right here on

the Kaggle Notebooks platform. So if

you're new to Kaggle Notebooks, don't worry. My name is Pong Lin and I'm a

worry. My name is Pong Lin and I'm a developer relations engineer at Google and I'll walk you through the steps you need to know before you begin building your first agent on the first day of

this 5-day event. Now, before we dive in, note that if you're not really comfortable running the code, that's okay. You can just read through these

okay. You can just read through these notebooks. But to really be able to get

notebooks. But to really be able to get some hands-on experience building agents, you'll want to copy and edit the notebook so that you can run through all the code yourself. So, to make a copy of

the notebook, you can click on the copy and edit button. And this will then create a copy of the notebook for you to use and run uh as your own. A notebook

is comprised of these cells. And these

cells can either be markdown cells or code cells like this one in gray.

Another markdown cell here and code cells below. And you'll see that if you

cells below. And you'll see that if you doubleclick these markdown cells, you can edit the contents within. And you

can just say, for example, hi. Press

shift enter or press the play button to render that markdown cell. For the code cell here, you can also again just press play or press shift enter in order for

it to run. And if this is the first time you're running a code cell, it might take a little bit of time for it to show that your draft session is now ready to go.

Now, just in terms of the order of the code cells that you run, you can see here there's two code cells here. One is

uh comprised of import statements and the second one has an agent that you're building. Now, if you run this code cell

building. Now, if you run this code cell first, it's going to return an error that the name agent is not defined. And

that's because you haven't yet actually run the import statements. So, make sure wherever possible that you're running these import statements in the right order. We're going to assume that you're

order. We're going to assume that you're going to be reading through the instructions from top to bottom. Uh run

a code cell, read more instructions, run another code cell. So, it should be in order from top to bottom generally speaking. So now if I run the code cell

speaking. So now if I run the code cell below, this should run without a problem. Okay. Excellent. Another thing

problem. Okay. Excellent. Another thing

that you'll need to consider is adding in your Gemini API key uh to the notebook. So of course, one way to do so

notebook. So of course, one way to do so is to just simply paste it in to Google API key in plain text, but we really don't recommend pasting your API keys in

your notebooks ever. And the best way to do this instead is to add it as a Kaggle secret, which I'll show you in a second.

But just as a reason as to why you don't want to paste in your API key in these notebooks is because if you do end up sharing your notebooks down the road by clicking on the share button then if you

make it public now suddenly everyone might accidentally sort of know your API key. So let's let's not do that. So, in

key. So let's let's not do that. So, in

order to add your API key to Kaggle secrets, go to the add-ons section at the top and then click on secrets here and then under secrets on the right hand

side, we have this menu where you can now click to add secret and then you can add in under the label

Google API_key and uh given the value which is your API key and then click on Save. Excellent. So

now we have our secret which is the Google API key and then we also have our actual AP API key hidden here. Now just

make sure that this checkbox is indeed ticked so that uh the notebook will recognize this uh particular API key when it's ready to import it. So this

code cell is actually going to import that API key from uh the secret in this uh in this notebook. So I can click on run and it should uh read the Google API

key into the current environment which will allow you to run your agent. And

just make sure to follow the instructions that will be provided on how you can request your API key from Google AI studio. So that's how you use Kaggle notebooks. Hope you enjoy the

Kaggle notebooks. Hope you enjoy the course and happy agent

Loading...

Loading video analysis...