Transcript · English → Turkish

Building Your First AI Agent

Bu videoda yapay zekâ ajanlarının ne olduğunu öğreneceksiniz,

sadece teoride değil, pratikte de.

Modern ajanların arkasındaki fikirlere bakacağız

ve ardından ilk yapay zekâ ajanınızı inşa edeceğiz

Google'ın ADK'sini kullanarak adım adım.

Sonunda, ajanların nasıl akıl yürüttüğünü,

hareket ettiğini ve uyum sağladığını anlayacaksınız.

Ve kendinizin çalıştırabileceği bir koda sahip olacaksınız.

Peki yapay zekâ ajanları nedir?

En basit düzeyde, bir ajan bir yazılımdır

sadece cevap vermekle kalmayan, karar verip harekete geçebilen.

Tek bir yanıt oluşturmak yerine

geleneksel bir sohbet robotu gibi,

isteğinize bakar,

hangi adımların atılması gerektiğini belirler,

belki bir API çağırır, kod çalıştırır,

sonuçlara bakar ve ardından ne yapacağına karar verir.

En net açıklamalardan biri

REACT araştırma makalesinden geliyor,

Dil Modellerinde Muhakeme ve Eylemi Sinerji Hâline Getirmek.

O makaledeki fikir basit ama güçlüydü.

Dil modelleri sadece tek seferde metin üretmemeli.

Aslında adım adım muhakeme edebilir,

bir araç veya API çağırmak gibi bir eylemde bulunabilir,

sonuçları gözlemleyebilir ve ardından bir sonraki adımda ne yapacağına karar verebilir.

Bu muhakeme, eylem, gözlem ve uyum sağlama döngüsü,

modern yapay zekâ ajanlarının çalışma şeklinin temelidir.

Ve bu, tanımlanma şekliyle de örtüşüyor.

Muhakeme, planlama ve hafıza yeteneklerine sahip,

uyum sağlayacak kadar özerkliğe sahip olan

ve kullanıcı adına kararlar veren sistemler.

Tabii, tüm ajanlar aynı şekilde davranmaz.

Onları düşünmenin faydalı bir yolu, üç geniş kalıba ayırmaktır.

İlk olarak, sıralı ajanlarımız var.

Bunlar bir montaj hattı gibi adım adım çalışır.

Birinci adım, sonra ikinci adım, sonra üçüncü adım.

Öngörülebilirdirler ama katıdırlar.

İkinci olarak, reaktif ajanlarımız var.

Bunlar o anda karar verirler.

Mevcut duruma bakarlar ve sorarlar:

"Bir sonraki adımda ne yapmalıyım?"

Belki bir seferinde A aracını, bir sonrakinde B aracını.

Esnektirler ama önceden plan yapmazlar.

Son olarak, planlı veya planlama yapan ajanlarımız var.

Bunlar bir plan taslağı hazırlamak için duraklar, sonra uygularlar.

Seyahat rezervasyonu yapmayı düşünün.

Öylece rastgele bir uçak bileti almazsınız.

Tarihleri, otelleri seçersiniz

ve ardından takip edeceğiniz adımların sırası budur.

Peki bunlardan hangisi sizin için doğru olanı?

Bu, probleme bağlıdır.

Basit, öngörülebilir akışlar için ardışık olanlar iyidir.

Dinamik olanlar için reaktif olanlar daha iyi çalışır.

Ve bağımlılıkları olan çok adımlı hedefler için

planlama yapan ajanları istersiniz.

Tamam, bu genel bakıştı.

Şimdi, gerçekten bir ajan inşa edelim.

böylece bu fikirleri iş başında görebilirsiniz.

Bir blog yazma ajanı inşa edeceğiz.

Ona bir konu verirsiniz, o da yapılandırılmış bir taslak oluşturur,

bu taslağı tam bir blog yazısına dönüştürür

ve ardından alternatif başlıklar ile ilgi çekici girişler önerir.

İşte ADK'nin kategorileri burada devreye giriyor.

Kodun üzerinden geçerken,

planlayıcı ve yazar ajanının nasıl birer LLM ajanı olduğuna dikkat edin,

ki bunlar bir model tarafından desteklenir.

Bunlar döngü ajanları içine sarılmıştır,

ki bunlar da ADK'deki iş akışı ajanlarıdır.

Doğrulama başarısız olursa bunlar yeniden denemeleri otomatik olarak yönetir.

Ve eğer bunun da ötesinde bir şey isteseydik,

ADK, özel bir ajanı genişletmemize de izin verirdi

temel ajandan alt sınıf türeterek.

Öyleyse ortamı kuralım

ve ardından kodun üzerinden satır satır geçelim.

İlk olarak, UV'yi kurmanız gerekiyor.

Bunu tam buradaki komutu çalıştırarak yapabilirsiniz.

İkinci olarak, Google ADK'yi kurmanız gerekiyor

çünkü bunda açıkça ADK kullanmamız gerekiyor.

Ve ardından IDE'nizde agent.py adında bir dosya oluşturalım.

Bu temel kütüphaneleri içe aktarmamız gerekiyor

ve ardından ilk temsilcimizi oluşturmaya başlayabiliriz.

Yani oluşturduğumuz ilk temsilci

blog planlayıcı olarak adlandırılıyor.

Tek görevi bir konuyu ele almak

ve onu yapılandırılmış bir taslağa dönüştürmektir.

Tanımlaması kolay olsun diye ona blog planlayıcı adını veriyoruz

ve hangi modeli kullanacağını söylüyoruz,

bu da ortam dosyamızdan geliyor.

Açıklama sadece insanların okuyabileceği bir nottur.

Girişin önemli kısmı

burada ona aslında ne üreteceğini söylüyoruz,

bu da bir başlığı olan bir markdown taslağı,

kısa bir giriş, dört ila altı bölüm

madde işaretleri ve bir sonuçtur.

Bunu açıkça belirterek çıktıyı çok daha güvenilir hale getiriyoruz.

Son olarak, çıktı anahtarına bakın.

Bunu 'blog taslağı' olarak ayarladık.

Bu, bu temsilcinin yazdığı her şeyin

bu ad altında ortak durumda saklanacağı anlamına gelir

böylece onu alacak bir sonraki temsilci

bunu otomatik olarak yapabilir.

Sırada, ikinci bir temsilci ekliyoruz:

taslak doğrulama denetleyicisi.

Bu yeni bir şey yazmaz,

sadece taslağı kontrol eder.

Talimatı katıdır.

Durumdaki taslakta bir başlık, bir giriş,

dört ila altı bölüm ve bir sonuç varsa,

'tamam' kelimesiyle yanıt vermelidir.

Eğer bir şey eksikse,

'tekrar dene' kelimesiyle yanıt vermeli

ve neyin yanlış olduğunu açıklamalıdır.

Bu sayede taslağı kabul edip etmeyeceğimize

veya tekrar deneyeceğimize otomatik olarak karar verebiliriz.

Planlayıcıyı ve denetleyiciyi birbirine bağlamak için

onları bir döngü temsilcisinin içine sardık.

"robust blog planner" adında.

Döngü önce planlayıcıyı çalıştırır,

ardından denetleyiciyi.

Denetleyici "tamam" derse işimiz biter.

Denetleyici "tekrar dene" derse,

döngü planlayıcıyı tekrar çalıştırır

aynı talimatlarla.

Bunu üç defaya kadar yapabilir.

Bu bize bir güvenlik ağı sağlar,

böylece model bir şeyi unutursa,

doğru yapmak için bir şansı daha olur.

Şimdi "blog writer" adında başka bir ajan oluşturuyoruz.

Bu ajan, az önce kaydettiğimiz taslağı alır

"blog_outline" içindeki

ve onu tam bir markdown blog yazısına dönüştürür.

Talimat ona nasıl yazacağını söyler.

Hedef kitlenin yazılım mühendisleri olduğunu varsaymalı,

temel bilgileri atlayıp pratik bilgilere odaklanmalı,

hem nasılını hem de nedenini açıklamalı

ve faydalı olan yerlerde kısa kod parçacıklarına yer vermelidir.

Ayrıca taslağın yapısını takip etmeli

ve uygun başlıklar kullanmalıdır.

Tamamlanan taslak, blog alt çizgi post altına kaydedilir

paylaşılan durumda,

bir sonraki adım için hazır.

Sırada, başka bir denetleyici ekleyeceğiz,

bu sefer gönderi için.

Buna blog gönderisi doğrulama denetleyicisi deniyor.

blog alt çizgi post kısmına bakar

ve makalenin bir girişi,

taslakla eşleşen bölümleri,

bir sonucu ve net açıklamaları olup olmadığını kontrol eder.

Geçerse, denetleyici tamam der.

Geçmezse, tekrar dene der ve gereken düzeltmeleri listeler.

Tıpkı planlamada olduğu gibi,

yazar ile denetleyicisini birleştirip

robust blog writer adında bir döngü aracına dönüştürüyoruz.

Bu, sistemin yazma adımını otomatik olarak tekrar denemesini sağlar,

doğrulama geçene kadar, en fazla üç kez.

Şimdi her bir döngüyü, yani robust blog planner'ı

ve robust blog writer'ı araç olarak sarmalıyoruz.

Kök ajanının onları doğrudan çağırmasını sağlayan şey budur

içeride ne olduğu konusunda endişelenmesine gerek kalmadan.

Son olarak, hepsini bir araya getiriyoruz

blogger adındaki kök ajanıyla.

Blogger için talimatlar basittir.

Bir kullanıcı ona bir konu verdiğinde,

önce bir taslak oluşturmak için planlayıcı aracını çağırır,

ardından tüm yazıyı taslak haline getirmek için yazar aracını çağırır

ve son olarak üç alternatif başlık ekler

ve iki tweet uzunluğunda kanca ekler.

Kök ajanının yalnızca kullanıma sunduğumuz iki araca erişimi vardır:

planlayıcı ve yazar.

Bu yüzden iş akışı net ve kontrollüdür.

Ona bir konu verirsiniz; planlar, yazar, kontrol eder

ve ardından size kusursuz bir blog yazısı sunar.

Artık ilk ajan betiğinizi başarıyla yazdınız.

Bir sonraki adım bunu gerçekten çalıştırmaktır.

Terminalinize gidin ve çalıştırın

bu komutu ADK web ile kullanarak.

Böylece her şeyi basit bir kullanıcı arayüzünde görüntüleyebilirsiniz.

Bu çalışmaya başladığında, yerel ADK web bağlantısını

tarayıcınızda açın ve doğrudan temsilciyle

etkileşime geçmeye başlayın.

Başlangıç olarak, ondan yapay zekâ temsilcileri için

en iyi 10 kullanım alanı hakkında bir blog oluşturmasını isteyeceğim.

Bakalım sonuçları nasıl planlıyor, yazıyor ve sunuyor.

Ardından alt temsilcileriniz, bir blog yazısı

oluşturmak için birlikte çalışacak.

Ve işte bu kadar.

Google'ın ADK'si ile ilk yapay zekâ temsilcinizi oluşturup çalıştırdınız.

Temsilcilerin ne olduğu fikrinden yola çıktık,

ardından kodun üzerinden adım adım geçtik

ve son olarak terminalde hayata geçişini gördük.

İzlediğiniz için teşekkürler.

Bu videoda bahsedilen tüm kaynaklar ve kodlar için

açıklama kutusuna göz atın.

Nasıl bağlanacağınızı öğrenmek için sıradaki videoya göz atın

yapay zekâ ajanınızı bir MCI'a.

End of transcript · 1,166 words · machine translated

Original transcript (English)

In this video, you're going to learn what AI agents are, not just in theory, but in practice. We'll look at the ideas behind modern agents, and then we'll build your very first AI agent step-by-step using Google's ADK.

By the end, you'll understand how agents reason, act, and adapt. And you'll have code that you can actually run yourself. So what are AI agents? At the simplest level, an agent is software

that doesn't just answer, it can decide and take action. Instead of generating a single response like a traditional chatbot, it looks at your request, figures out what steps need to be taken,

maybe calls an API, runs code, looks at the results, and then decides what to do next. One of the clearest explanations comes from the research paper REACT, Synergizing Reasoning and Acting in Language Models.

The idea in that paper was simple but powerful. Language models shouldn't just generate text in one go. They can actually reason step-by-step, take an action like calling a tool or API, observe the results, and then decide what to do next.

That cycle of reasoning, acting, observing, and adjusting is the foundation of how modern AI agents work. And it lines up with how it's defined. Systems with reasoning, planning, and memory, with enough autonomy to adapt

and make decisions on behalf of the user. Now, not all agents behave the same way. A useful way to think about them is in three broad patterns. First, we have sequential agents. These run step-by-step like an assembly line.

Step one, then step two, then step three. They're predictable, but rigid. Second, we have reactive agents. These decide in the moment. They look at the current state and ask,

what should I do next? Maybe tool A one time, tool B the next. They're flexible, but they don't plan ahead. Lastly, we have deliberate or planning agents. These pause to sketch a plan, then execute.

Think about booking travel. You don't just buy a flight randomly. You pick dates, hotels, and then that's the order of steps that you follow through. So which of these is the right one for you?

It depends on the problem. For simple, predictable flows, sequential is fine. For dynamic, reactive works better. And for multi-step goals with dependencies, you want planning agents.

Okay, that's the high-level view. Now, let's actually build an agent so you can see these ideas in action. We'll build a blog writing agent. You give it a topic, it will generate a structured outline,

turn that outline into a full blog post, and then suggest alternative titles and hooks. This is where ADK's categories comes in. As we walk through the code, notice how the planner and writer agent are LLM agents,

which are powered by a model. They're wrapped in loop agents, which are workflow agents in ADK. These handle retries automatically if validation fails. And if we ever wanted something beyond that,

ADK would also let us extend a custom agent by subclassing the base agent. So let's set up the environment and then go line by line through the code. First off, you need to install UV.

You can do that by running the command right here. Secondly, you need to install Google ADK because we need to obviously use ADK in this. And then let's create a file called agent.py in your IDE. We need to import these key libraries

and then we can start building out our very first agent. So the first agent that we're building out is called the blog planner. Its only job is to take a topic and turn it into a structured outline.

We give it the name blog planner so it's easy to identify and we tell it which model to use, which comes from our environment file. The description is just a human readable note. The important part of the introduction

is here we actually tell it what to produce, which is a markdown outline with a title, a short introduction, four to six sections with bullet points and a conclusion. By spelling that out, we make the output much more reliable.

Finally, look at the output key. We set it to blog outline. This means whatever this agent writes will be stored in shared state under that name so that the next agent that can pick it up

can do it automatically. Next, we add a second agent, the outline validation checker. This one doesn't write anything new, it just checks the outline.

Its instruction is strict. If the outline in state has a title, an intro, four to six sections, and a conclusion, it must answer with the word, okay. If something is missing,

it must answer with the word retry and explain what's wrong. That way we can automatically decide whether to accept the outline or try again. To connect the planner and the checker,

we've wrapped them inside a loop agent called robust blog planner. The loop first runs the planner, then the checker. If the checker says, okay, we're done.

If the checker says, retry, the loop runs the planner again with the same instructions. It can do this up to three times. This gives us a safety net,

so if the model forgets something, it has another chance to get it right. Now we create another agent called blog writer. This one takes the outline we just saved in blog underscore outline

and turns it into a full markdown blog post. The instruction tells it how to write. It should assume the audience is software engineers, skip the basics and focus on practical insights, explain both the how and the why

and include short code snippets where helpful. It should also follow the structure of the outline with proper headings. The finished draft is saved under blog underscore post in shared state,

ready for the next step. Next up, we're gonna add another checker, this time for the post. It's called blog post validation checker. It looks at blog underscore post

and checks if the article has an introduction, sections that match the outline, a conclusion and clear explanations. If it passes, the checker says, okay. If not, it says retry and list the fixes which are needed.

Just like with planning, we combine the writer and its checker into a loop agent called robust blog writer. This makes the system automatically retry the writing step until the validation passes up to three times.

Now we wrap each loop, the robust blog planner and the robust blog writer as tools. This is what lets the root agent call them directly without worrying about what's happening inside. Finally, we put it all together

with the root agent called blogger. The instructions for blogger are simple. When a user gives it a topic, first it calls the planner tool to make an outline, then it calls the writer tool to draft the full post

and finally it adds three alternative titles and two tweet length hooks. The root agent only has access to the two tools we exposed, the planner and the writer. So it's workflow is clear and controlled.

You give it a topic, it plans, it writes, it checks, and then it gives you a polished blog post. You've now successfully written your first agent script. The next step is to actually run it. Head into your terminal and launch it

using this command with ADK web. So you can view everything inside a simple UI. Once that's running, open the local ADK web link in your browser and start interacting with the agent directly.

To kick things off, I'm going to ask it to generate a blog on the top 10 use cases for AI agents. Let's see how it plans, writes, and delivers the results. Your sub-agents will then work together to create a blog post.

And that's it. You've built and run your first AI agent with Google's ADK. We started from the idea of what agents are, then walked through the code step-by-step, and finally saw it come to life in terminal.

Thank you for watching. Check out the description box for all the resources and code mentioned in this video. Check out this next video to learn how to connect your AI agent to an MCI.

iPhone app Translate videos on your iPhone Paste a TikTok, Instagram or X link, add subtitles in your language and save the video to Photos.

Read any video in your language

Paste a link from X, TikTok, YouTube or Instagram. You get a page like this one.