১. এই ল্যাবের উদ্দেশ্য
এই হ্যান্ডস-অন ল্যাবে আপনি ADK (এজেন্ট ডেভেলপমেন্ট কিট) ভিজ্যুয়াল বিল্ডার ব্যবহার করে এজেন্ট তৈরি করার পদ্ধতি শিখবেন। ADK (এজেন্ট ডেভেলপমেন্ট কিট) ভিজ্যুয়াল বিল্ডার, ADK (এজেন্ট ডেভেলপমেন্ট কিট) এজেন্ট তৈরি করার একটি লো-কোড পদ্ধতি প্রদান করে। আপনি অ্যাপ্লিকেশনটি স্থানীয়ভাবে পরীক্ষা করা এবং ক্লাউড রান- এ ডেপ্লয় করার পদ্ধতিও শিখবেন।
আপনি যা শিখবেন
- এডিকে (এজেন্ট ডেভেলপমেন্ট কিট) -এর মূল বিষয়গুলো বুঝুন।
- ADK (এজেন্ট ডেভেলপমেন্ট কিট) ভিজ্যুয়াল বিল্ডারের মূল বিষয়গুলো বুঝুন।
- GUI টুল ব্যবহার করে কীভাবে এজেন্ট তৈরি করতে হয় তা শিখুন।
- ক্লাউড রান- এ কীভাবে সহজে এজেন্টগুলো স্থাপন ও ব্যবহার করা যায় তা জানুন।

চিত্র ১: ADK ভিজ্যুয়াল বিল্ডারের সাহায্যে আপনি লো-কোড পদ্ধতিতে GUI ব্যবহার করে এজেন্ট তৈরি করতে পারেন।
২. প্রকল্প স্থাপন
- আপনার যদি আগে থেকে ব্যবহারযোগ্য কোনো প্রজেক্ট না থাকে, তাহলে আপনাকে GCP কনসোলে একটি নতুন প্রজেক্ট তৈরি করতে হবে। প্রজেক্ট সিলেক্টর (গুগল ক্লাউড কনসোলের উপরের বাম দিকে) থেকে প্রজেক্টটি নির্বাচন করুন।

চিত্র ২: গুগল ক্লাউড লোগোর ঠিক পাশের বক্সে ক্লিক করলে আপনি আপনার প্রজেক্ট নির্বাচন করতে পারবেন। আপনার প্রজেক্টটি নির্বাচিত হয়েছে কিনা তা নিশ্চিত করুন।
- এই ল্যাবে আমরা আমাদের কাজগুলো করার জন্য ক্লাউড শেল এডিটর ব্যবহার করব। ক্লাউড শেল খুলুন এবং এটি ব্যবহার করে প্রজেক্টটি সেট করুন।
- সরাসরি ক্লাউড শেল এডিটর- এ যেতে এই লিঙ্কে ক্লিক করুন।
- যদি টার্মিনালটি আগে থেকে খোলা না থাকে, তাহলে মেনু থেকে Terminal>New Terminal-এ ক্লিক করে এটি খুলুন। এই টিউটোরিয়ালের সমস্ত কমান্ড আপনি এই টার্মিনালে চালাতে পারবেন।
- ক্লাউড শেল টার্মিনালে নিম্নলিখিত কমান্ডটি ব্যবহার করে আপনি যাচাই করতে পারেন যে প্রজেক্টটি ইতিমধ্যেই প্রমাণীকৃত কিনা।
gcloud auth list
- আপনার প্রজেক্টটি নিশ্চিত করতে ক্লাউড শেলে নিম্নলিখিত কমান্ডটি চালান।
gcloud config list project
- প্রজেক্ট আইডিটি কপি করুন এবং এটি সেট করতে নিম্নলিখিত কমান্ডটি ব্যবহার করুন।
gcloud config set project <YOUR_PROJECT_ID>
- আপনি যদি আপনার প্রজেক্ট আইডি মনে রাখতে না পারেন, তাহলে আপনি আপনার সমস্ত প্রজেক্ট আইডি তালিকাভুক্ত করতে পারেন।
gcloud projects list
৩. এপিআই সক্রিয় করুন
এই ল্যাবটি চালানোর জন্য আমাদের কিছু এপিআই পরিষেবা সক্রিয় করতে হবে। ক্লাউড শেলে নিম্নলিখিত কমান্ডটি চালান।
gcloud services enable aiplatform.googleapis.com
gcloud services enable cloudresourcemanager.googleapis.com
এপিআইগুলো চালু করা হচ্ছে
- ভার্টেক্স এআই এপিআই (
aiplatform.googleapis.com) ভার্টেক্স এআই প্ল্যাটফর্মে প্রবেশের সুযোগ করে দেয়, যার ফলে আপনার অ্যাপ্লিকেশন টেক্সট জেনারেশন, চ্যাট সেশন এবং ফাংশন কলিংয়ের জন্য জেমিনি মডেলের সাথে যোগাযোগ করতে পারে। - Cloud Resource Manager API (
cloudresourcemanager.googleapis.com) allows you to programmatically manage metadata for your Google Cloud projects, such as project ID and name, which is often required by other tools and SDKs to verify project identity and permissions.
৪. আপনার ক্রেডিটগুলো প্রয়োগ করা হয়েছে কিনা তা নিশ্চিত করুন।
প্রজেক্ট সেটআপ পর্যায়ে আপনি বিনামূল্যের ক্রেডিটের জন্য আবেদন করেছেন, যা আপনাকে গুগল ক্লাউডের পরিষেবাগুলো ব্যবহার করতে সক্ষম করে। আপনি যখন ক্রেডিটগুলো প্রয়োগ করেন, তখন 'গুগল ক্লাউড প্ল্যাটফর্ম ট্রায়াল বিলিং অ্যাকাউন্ট' নামে একটি নতুন বিনামূল্যের বিলিং অ্যাকাউন্ট তৈরি হয়। ক্রেডিটগুলো প্রয়োগ হয়েছে কিনা তা নিশ্চিত করতে, ক্লাউড শেল এডিটরে নিম্নলিখিত ধাপগুলো অনুসরণ করুন।
curl -s https://raw.githubusercontent.com/haren-bh/gcpbillingactivate/main/activate.py | python3
সফল হলে, আপনি নীচের মতো ফলাফল দেখতে পাবেন: যদি আপনি "প্রজেক্ট সফলভাবে লিঙ্ক করা হয়েছে" দেখতে পান, তাহলে আপনার বিলিং অ্যাকাউন্টটি সঠিকভাবে সেট করা আছে। উপরের ধাপটি অনুসরণ করে আপনি পরীক্ষা করতে পারেন আপনার অ্যাকাউন্টটি লিঙ্ক করা আছে কিনা; লিঙ্ক করা না থাকলে, এটি আপনার জন্য লিঙ্ক করে দেবে। আপনি যদি প্রজেক্ট নির্বাচন না করে থাকেন, তবে এটি আপনাকে একটি প্রজেক্ট বেছে নিতে বলবে, অথবা আপনি প্রজেক্ট সেটআপের ধাপগুলো অনুসরণ করে আগে থেকেই তা করে নিতে পারেন। 
চিত্র ৩: বিলিং অ্যাকাউন্ট লিঙ্ক করার নিশ্চিতকরণ
৫. এজেন্ট ডেভেলপমেন্ট কিট-এর পরিচিতি
এজেন্টিক অ্যাপ্লিকেশন নির্মাণকারী ডেভেলপারদের জন্য এজেন্ট ডেভেলপমেন্ট কিট বেশ কিছু গুরুত্বপূর্ণ সুবিধা প্রদান করে:
- মাল্টি-এজেন্ট সিস্টেম : একটি শ্রেণিবিন্যাসে একাধিক বিশেষায়িত এজেন্টকে একত্রিত করে মডিউলার এবং স্কেলেবল অ্যাপ্লিকেশন তৈরি করুন। জটিল সমন্বয় এবং দায়িত্ব অর্পণ সক্ষম করুন।
- Rich Tool Ecosystem : Equip agents with diverse capabilities: use pre-built tools (Search, Code Execution, etc.), create custom functions, integrate tools from third-party agent frameworks (LangChain, CrewAI), or even use other agents as tools.
- নমনীয় অর্কেস্ট্রেশন : অনুমানযোগ্য পাইপলাইনের জন্য ওয়ার্কফ্লো এজেন্ট (
SequentialAgent,ParallelAgent, এবংLoopAgent) ব্যবহার করে ওয়ার্কফ্লো নির্ধারণ করুন, অথবা অভিযোজিত আচরণের জন্য এলএলএম-চালিত ডাইনামিক রাউটিং (LlmAgentট্রান্সফার) কাজে লাগান। - সমন্বিত ডেভেলপার অভিজ্ঞতা : একটি শক্তিশালী CLI এবং একটি ইন্টারেক্টিভ ডেভ UI ব্যবহার করে স্থানীয়ভাবে ডেভেলপ, টেস্ট এবং ডিবাগ করুন। ইভেন্ট, স্টেট এবং এজেন্ট এক্সিকিউশন ধাপে ধাপে পর্যবেক্ষণ করুন।
- অন্তর্নির্মিত মূল্যায়ন : পূর্বনির্ধারিত টেস্ট কেসগুলোর সাথে চূড়ান্ত প্রতিক্রিয়ার গুণমান এবং ধাপে ধাপে কার্য সম্পাদনের গতিপথ উভয়ই মূল্যায়ন করে এজেন্টের কর্মক্ষমতা পদ্ধতিগতভাবে যাচাই করুন।
- ডেপ্লয়মেন্টের জন্য প্রস্তুত : আপনার এজেন্টগুলোকে কন্টেইনারাইজ করে যেকোনো জায়গায় ডেপ্লয় করুন – স্থানীয়ভাবে চালান, Vertex AI Agent Engine-এর সাহায্যে স্কেল করুন, অথবা Cloud Run বা Docker ব্যবহার করে কাস্টম ইনফ্রাস্ট্রাকচারে ইন্টিগ্রেট করুন।
যদিও অন্যান্য জেন এআই এসডিকে বা এজেন্ট ফ্রেমওয়ার্কগুলোও আপনাকে মডেলগুলো কোয়েরি করতে এবং এমনকি বিভিন্ন টুলের মাধ্যমে সেগুলোকে আরও শক্তিশালী করতে দেয়, একাধিক মডেলের মধ্যে গতিশীল সমন্বয়ের জন্য আপনার পক্ষ থেকে যথেষ্ট পরিমাণ পরিশ্রমের প্রয়োজন হয়।
এজেন্ট ডেভেলপমেন্ট কিট এই টুলগুলোর চেয়ে একটি উন্নত কাঠামো প্রদান করে, যা আপনাকে জটিল কিন্তু সহজে রক্ষণাবেক্ষণযোগ্য ওয়ার্কফ্লোর জন্য একাধিক এজেন্টকে একে অপরের সাথে সহজে সংযুক্ত করার সুযোগ দেয়।

চিত্র ৪: এডিকে (এজেন্ট ডেভেলপমেন্ট কিট) -এর অবস্থান
সাম্প্রতিক সংস্করণগুলিতে ADK (এজেন্ট ডেভেলপমেন্ট কিট) -এ একটি ADK ভিজ্যুয়াল বিল্ডার টুল যুক্ত করা হয়েছে, যা আপনাকে লো-কোড ব্যবহার করে ADK (এজেন্ট ডেভেলপমেন্ট কিট) এজেন্ট তৈরি করতে দেয়। এই ল্যাবে আমরা ADK ভিজ্যুয়াল বিল্ডার টুলটি বিস্তারিতভাবে জানব।
৬. ADK ইনস্টল করুন এবং আপনার পরিবেশ সেটআপ করুন।
প্রথমত, আমাদের পরিবেশ প্রস্তুত করতে হবে যাতে আমরা ADK (এজেন্ট ডেভেলপমেন্ট কিট) চালাতে পারি। এই ল্যাবে আমরা ADK (এজেন্ট ডেভেলপমেন্ট কিট) চালাব এবং গুগল ক্লাউডের ক্লাউড শেল এডিটরে সমস্ত কাজ সম্পাদন করব।
একটি ক্লাউড শেল এডিটর প্রস্তুত করুন
- সরাসরি ক্লাউড শেল এডিটর- এ যেতে এই লিঙ্কে ক্লিক করুন।
- চালিয়ে যান-এ ক্লিক করুন।
- ক্লাউড শেল অনুমোদন করতে বলা হলে, Authorize-এ ক্লিক করুন।
- এই ল্যাবের বাকি অংশ জুড়ে, আপনি ক্লাউড শেল এডিটর এবং ক্লাউড শেল টার্মিনাল ব্যবহার করে এই উইন্ডোটিকে আপনার IDE হিসেবে ব্যবহার করে কাজ করতে পারবেন।
- Open a new Terminal using Terminal>New Terminal in the Cloud Shell Editor. All the commands below will be run on this terminal.
ADK ভিজ্যুয়াল এডিটর শুরু করুন
- গিটহাব থেকে প্রয়োজনীয় সোর্স ক্লোন করতে এবং প্রয়োজনীয় লাইব্রেরিগুলো ইনস্টল করতে নিম্নলিখিত কমান্ডগুলো চালান। ক্লাউড শেল এডিটর -এ খোলা টার্মিনালে কমান্ডগুলো রান করুন।
#create the project directory
mkdir ~/adkui
cd ~/adkui
- আমরা পাইথন এনভায়রনমেন্ট তৈরি করতে uv ব্যবহার করব ( ক্লাউড শেল এডিটর টার্মিনালে চালান):
#Install uv if you do not have installed yet
pip install uv
#go to the project directory
cd ~/adkui
#Create the virtual environment
uv venv
#use the newly created environment
source .venv/bin/activate
#install libraries
uv pip install google-adk==1.22.1
uv pip install python-dotenv
দ্রষ্টব্য : যদি কখনও টার্মিনাল পুনরায় চালু করার প্রয়োজন হয়, তাহলে " source .venv/bin/activate " কমান্ডটি চালিয়ে আপনার পাইথন এনভায়রনমেন্ট সেট করে নিন।
- এডিটরে View->Toggle hidden files-এ যান। এবং adkui ফোল্ডারে নিম্নলিখিত বিষয়বস্তু সহ একটি .env ফাইল তৈরি করুন।
#go to adkui folder
cd ~/adkui
cat <<EOF>> .env
GOOGLE_GENAI_USE_VERTEXAI=1
GOOGLE_CLOUD_PROJECT=$(gcloud config get-value project)
GOOGLE_CLOUD_LOCATION=us-central1
IMAGEN_MODEL="imagen-3.0-generate-002"
GENAI_MODEL="gemini-2.5-flash"
EOF
৭. ADK ভিজ্যুয়াল বিল্ডার ব্যবহার করে একটি সহজ এজেন্ট তৈরি করুন
এই অংশে আমরা ADK ভিজ্যুয়াল বিল্ডার ব্যবহার করে একটি সাধারণ এজেন্ট তৈরি করব। ADK ভিজ্যুয়াল বিল্ডার হলো একটি ওয়েব-ভিত্তিক টুল যা ADK (এজেন্ট ডেভেলপমেন্ট কিট) এজেন্ট তৈরি এবং পরিচালনার জন্য একটি ভিজ্যুয়াল ওয়ার্কফ্লো ডিজাইন পরিবেশ প্রদান করে। এটি আপনাকে একটি শিক্ষানবিস-বান্ধব গ্রাফিক্যাল ইন্টারফেসে আপনার এজেন্ট ডিজাইন, বিল্ড এবং পরীক্ষা করার সুযোগ দেয় এবং এতে এজেন্ট তৈরিতে সাহায্য করার জন্য একটি এআই-চালিত অ্যাসিস্ট্যান্টও রয়েছে।

চিত্র ৫: এডিকে ভিজ্যুয়াল বিল্ডার
- টার্মিনালে adkui টপ ডিরেক্টরিতে ফিরে যান এবং এজেন্টটিকে স্থানীয়ভাবে চালানোর জন্য নিম্নলিখিত কমান্ডটি চালান ( ক্লাউড শেল এডিটর টার্মিনালে চালান)। আপনি ADK সার্ভারটি চালু করতে সক্ষম হবেন এবং টার্মিনালে চিত্র ৬-এর মতো ফলাফল দেখতে পাবেন।
#go to the directory adkui
cd ~/adkui
# Run the following command to run ADK locally
adk web

চিত্র ৬: ADK অ্যাপ্লিকেশন চালু হওয়া
- ADK (এজেন্ট ডেভেলপমেন্ট কিট) ব্রাউজার ভিত্তিক GUI টুলটি খোলার জন্য টার্মিনালে প্রদর্শিত http:// ইউআরএল-এর উপর Ctrl+Click (MacOS-এর জন্য CMD+Click ) করুন।

চিত্র ৭: ADK ওয়েব UI, ADK-এর নিম্নলিখিত উপাদানসমূহ রয়েছে: ১: লাইট এবং ডার্ক মোড টগল করা ২: প্যানেল সংকুচিত করা ৩: এজেন্ট তৈরি করা ৪: এজেন্ট সম্পাদনা করা
- নতুন এজেন্ট তৈরি করতে "+" বোতামটি চাপুন।

চিত্র ৮ : নতুন অ্যাপ তৈরির ডায়ালগ বক্স
- 'Agent1' নামটি দিন এবং তৈরি করুন।

চিত্র ৯: এজেন্ট বিল্ডারের জন্য UI
- প্যানেলটি তিনটি প্রধান অংশে বিভক্ত: বাম দিকে রয়েছে GUI-ভিত্তিক এজেন্ট তৈরির কন্ট্রোল, মাঝখানে আপনার অগ্রগতির একটি ভিজ্যুয়ালাইজেশন এবং ডান দিকে রয়েছে স্বাভাবিক ভাষা ব্যবহার করে এজেন্ট তৈরির অ্যাসিস্ট্যান্ট।
- আপনার এজেন্ট সফলভাবে তৈরি করা হয়েছে। এগিয়ে যেতে সেভ বাটনে ক্লিক করুন। ( দ্রষ্টব্য: আপনার পরিবর্তনগুলি যাতে হারিয়ে না যায়, সেজন্য সেভ বাটনটি চাপা আবশ্যক।)
- এজেন্টটি এখন পরীক্ষার জন্য প্রস্তুত। শুরু করতে, চ্যাট বক্সে একটি প্রম্পট লিখুন, যেমন:
Hi, what can you do?

চিত্র ১০: এজেন্টটির পরীক্ষা।
৭. এডিটরে ফিরে এসে, চলুন নতুন তৈরি হওয়া ফাইলগুলো পরীক্ষা করে দেখি। আপনি বাম দিকে এক্সপ্লোরারটি দেখতে পাবেন। adkgui ফোল্ডারে যান এবং Agent 1 ডিরেক্টরিটি খুঁজে পেতে এটিকে এক্সপ্যান্ড করুন। ফোল্ডারটির ভেতরে, আপনি এজেন্টকে সংজ্ঞায়িতকারী YAML ফাইলটি দেখতে পাবেন, যা নিচের চিত্রে দেখানো হয়েছে।

চিত্র ১১: YAML ফাইল ব্যবহার করে এজেন্টের সংজ্ঞা
- এবার চলুন GUI এডিটরে ফিরে যাই এবং এজেন্টটিতে কয়েকটি ফিচার যোগ করি। এটি করার জন্য এডিট বাটনটি চাপুন (চিত্র ৭, কম্পোনেন্ট নম্বর ৪, কলম আইকনটি দেখুন)।
- আমরা এজেন্টের জন্য একটি গুগল সার্চ ফিচার যোগ করতে যাচ্ছি। এর জন্য, গুগল সার্চকে এজেন্টের ব্যবহারযোগ্য একটি টুল হিসেবে যুক্ত করতে হবে। এটি করার জন্য, স্ক্রিনের নিচের বাম দিকে থাকা টুলস সেকশনের পাশের "+" চিহ্নে ক্লিক করুন এবং মেনু থেকে বিল্ট-ইন টুল-এ ক্লিক করুন ( চিত্র ১২ দেখুন )।

চিত্র ১২: একজন এজেন্টের সাথে একটি নতুন টুল যুক্ত করা
- বিল্ট-ইন টুলের তালিকা থেকে google_search নির্বাচন করুন এবং Create-এ ক্লিক করুন (চিত্র ১২ দেখুন) । এটি আপনার এজেন্টে গুগল সার্চকে একটি টুল হিসেবে যুক্ত করবে।
- পরিবর্তনগুলো সংরক্ষণ করতে সেভ বাটনটি চাপুন।

চিত্র ১৩: ADK ভিজ্যুয়াল বিল্ডার UI-তে উপলব্ধ টুলগুলির তালিকা
- এখন আপনি এজেন্টটি পরীক্ষা করার জন্য প্রস্তুত। প্রথমে ADK সার্ভারটি রিস্টার্ট করুন। যে টার্মিনাল থেকে আপনি ADK (এজেন্ট ডেভেলপমেন্ট কিট) সার্ভারটি চালু করেছিলেন, সেখানে যান এবং সার্ভারটি তখনও চালু থাকলে তা বন্ধ করতে CTRL+C চাপুন। সার্ভারটি পুনরায় চালু করতে নিম্নলিখিত কমান্ডটি চালান।
#make sure you are in the right folder.
cd ~/adkui
#start the server
adk web
- স্ক্রিনে প্রদর্শিত ইউআরএল-এর (যেমন, http://localhost:8000 ) উপর Ctrl+Click করুন। ব্রাউজার ট্যাবে ADK (Agent Development Kit) GUI প্রদর্শিত হবে।
- এজেন্টদের তালিকা থেকে এজেন্ট১ নির্বাচন করুন। আপনার এজেন্ট এখন গুগল সার্চ করতে পারবে। চ্যাট বক্সে নিম্নলিখিত প্রম্পটটি দিয়ে পরীক্ষা করুন।
What is the weather today in Yokohama?
গুগল সার্চ করলে আপনি নিচের মতো করে উত্তরটি দেখতে পাবেন। 
চিত্র ১৪: এজেন্টের সাহায্যে গুগল সার্চ
- এখন চলুন এডিটরে ফিরে যাই এবং এই ধাপে তৈরি হওয়া কোডটি পরীক্ষা করি। এডিটর এক্সপ্লোরার সাইড প্যানেল থেকে root_agent.yaml- এ ক্লিক করে এটি খুলুন। নিশ্চিত করুন যে টুল হিসেবে google_search যুক্ত হয়েছে (চিত্র ১৫)।

চিত্র ১৫: এজেন্ট১- এ গুগল সার্চ একটি টুল হিসেবে যুক্ত হওয়ার নিশ্চিতকরণ।
৮. এজেন্টটিকে ক্লাউড রানে স্থাপন করুন
এবার তৈরি করা এজেন্টটি ক্লাউড রান- এ ডেপ্লয় করা যাক! ক্লাউড রান- এর মাধ্যমে আপনি একটি সম্পূর্ণ পরিচালিত প্ল্যাটফর্মে দ্রুত অ্যাপ বা ওয়েবসাইট তৈরি করতে পারেন।
আপনি পরিকাঠামো ব্যবস্থাপনার প্রয়োজন ছাড়াই ফ্রন্টএন্ড ও ব্যাকএন্ড পরিষেবা, ব্যাচ জব, এলএলএম হোস্ট এবং কিউ প্রসেসিং ওয়ার্কলোড চালাতে পারেন।
ক্লাউড শেল এডিটর টার্মিনালে, যদি আপনি এখনও ADK (এজেন্ট ডেভেলপমেন্ট কিট) সার্ভারটি চালু রাখেন, তবে এটি বন্ধ করতে Ctrl+C চাপুন।
- প্রজেক্টের রুট ডিরেক্টরিতে যান।
cd ~/adkui
- ডিপ্লয় কোডটি নিন। কমান্ডটি চালানোর পর আপনি ক্লাউড শেল এডিটর এক্সপ্লোরার প্যানে deploycloudrun.py ফাইলটি দেখতে পাবেন।
curl -LO https://raw.githubusercontent.com/haren-bh/codelabs/main/adk_visual_builder/deploycloudrun.py
- Check the deploy options in deploycloudrun.py. We will use the adk deploy command to deploy our agent to Cloud Run . ADK (Agent Development Kit) has the built in option to deploy the agent to Cloud Run . We need to specify the parameters such as Google Cloud Project ID, Region, etc. For the app path this script assumes that agent_path=./Agent1. We will also create a new service account with the necessary permissions and attach it to Cloud Run . Cloud Run needs access to services like Vertex AI, Cloud Storage to run the Agent.
command = [
"adk", "deploy", "cloud_run",
f"--project={project_id}",
f"--region={location}",
f"--service_name={service_name}",
f"--app_name={app_name}",
f"--artifact_service_uri=memory://",
f"--with_ui",
agent_path,
f"--",
f"--service-account={sa_email}",
]
- deploycloudrun.py স্ক্রিপ্টটি চালান। নিচের চিত্রে দেখানো অনুযায়ী ডিপ্লয়মেন্ট শুরু হওয়া উচিত।
python3 deploycloudrun.py
আপনি যদি নীচের মতো নিশ্চিতকরণ বার্তা পান, তাহলে সমস্ত বার্তার জন্য Y এবং Enter চাপুন। depoycloudrun.py ধরে নেয় যে আপনার এজেন্ট উপরে তৈরি করা Agent1 ফোল্ডারে আছে।

চিত্র ১৬: ক্লাউড রান-এ এজেন্ট স্থাপন করা হচ্ছে, যেকোনো নিশ্চিতকরণ বার্তার জন্য Y চাপুন।
- ডেপ্লয়মেন্ট সম্পূর্ণ হলে আপনি https://agent1service-78833623456.us-central1.run.app- এর মতো একটি সার্ভিস ইউআরএল দেখতে পাবেন।
- অ্যাপটি চালু করতে আপনার ওয়েব ব্রাউজারে ইউআরএলটি অ্যাক্সেস করুন।

Figure 17: Agent running in Cloud Run
৯. সাব-এজেন্ট এবং কাস্টম টুল সহ একজন এজেন্ট তৈরি করুন
পূর্ববর্তী অংশে আপনি একটি অন্তর্নির্মিত গুগল সার্চ টুলসহ একটি একক এজেন্ট তৈরি করেছিলেন। এই অংশে আপনি একটি মাল্টি-এজেন্ট সিস্টেম তৈরি করবেন যেখানে আমরা এজেন্টদের কাস্টম টুল ব্যবহার করার অনুমতি দেব।
- প্রথমে ADK (এজেন্ট ডেভেলপমেন্ট কিট) সার্ভারটি রিস্টার্ট করুন। যে টার্মিনাল থেকে আপনি ADK (এজেন্ট ডেভেলপমেন্ট কিট) সার্ভারটি চালু করেছিলেন, সেখানে যান এবং সার্ভারটি তখনও চালু থাকলে তা বন্ধ করতে CTRL+C চাপুন । সার্ভারটি পুনরায় চালু করতে নিম্নলিখিত কমান্ডটি চালান।
#make sure you are in the right folder.
cd ~/adkui
#start the server
adk web
- স্ক্রিনে প্রদর্শিত ইউআরএল-এর (যেমন, http://localhost:8000 ) উপর Ctrl+Click করুন। ব্রাউজার ট্যাবে ADK (Agent Development Kit) GUI প্রদর্শিত হবে।
- নতুন এজেন্ট তৈরি করতে "+" বোতামে ক্লিক করুন। এজেন্ট ডায়ালগে "Agent2" (চিত্র 18) লিখুন এবং "Create" এ ক্লিক করুন।

চিত্র ১৮: একটি নতুন এজেন্ট অ্যাপ তৈরি করা।
- Agent2-এর নির্দেশাবলী অংশে নিম্নলিখিতগুলি লিখুন।
You are an agent that takes image creation instruction from the user and passes it to your sub agent
- এখন আমরা রুট এজেন্টে একটি সাব এজেন্ট যুক্ত করব। এটি করার জন্য, বাম প্যানেলের নীচে থাকা সাব এজেন্ট মেনুর বাম পাশের "+" বোতামে ক্লিক করুন (চিত্র ১৯) এবং " LLM Agent "-এ ক্লিক করুন। এটি রুট এজেন্টের একটি নতুন সাব এজেন্ট হিসাবে একটি নতুন এজেন্ট তৈরি করবে।

চিত্র ১৯: একজন নতুন সাব এজেন্ট যোগ করুন।
- sub_agent_1- এর নির্দেশাবলীতে নিম্নলিখিত লেখাটি প্রবেশ করান।
You are an Agent that can take instructions about an image and create an image using the create_image tool.
- Now lets add a custom tool on this sub agent. This tool will call the Imagen model to generate an image using the user's instructions. To do so, first click on the Sub Agent created in the previous step and click "+" button next to the Tools menu. From the list of the tool options click on " Function tool ". This tool will allow us to add our own custom code to the tool.

চিত্র ২০: একটি নতুন টুল তৈরি করতে ফাংশন টুলে ক্লিক করুন। ৮. ডায়ালগ বক্সে টুলটির নাম দিন Agent2.image_creation_tool.create_image । 
চিত্র ২১: টুলের নাম যোগ করুন
- পরিবর্তনগুলো সংরক্ষণ করতে সেভ বাটনে ক্লিক করুন।
- ক্লাউড শেল এডিটর টার্মিনালে adk সার্ভারটি বন্ধ করতে Ctrl+S চাপুন।
- image_creation_tool.py ফাইলটি তৈরি করতে টার্মিনালে নিম্নলিখিত কমান্ডটি প্রবেশ করান।
touch ~/adkui/Agent2/image_creation_tool.py
- ক্লাউড শেল এডিটর -এর এক্সপ্লোরার প্যানে নতুন তৈরি করা image_creation_tool.py ফাইলটিতে ক্লিক করে সেটি খুলুন। এরপর image_creation_tool.py ফাইলের ভেতরের লেখাগুলো নিচের কোড দিয়ে পরিবর্তন করে সেভ করুন (Ctrl+S) ।
import os
import io
import vertexai
from vertexai.preview.vision_models import ImageGenerationModel
from dotenv import load_dotenv
import uuid
from typing import Union
from datetime import datetime
from google import genai
from google.genai import types
from google.adk.tools import ToolContext
import logging
# Configure logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
async def create_image(prompt: str,tool_context: ToolContext) -> Union[bytes, str]:
"""
Generates an image based on a text prompt using a Vertex AI Imagen model.
Args:
prompt: The text prompt to generate the image from.
Returns:
The binary image data (PNG format) on success, or an error message string on failure.
"""
print(f"Attempting to generate image for prompt: '{prompt}'")
try:
# Load environment variables from .env file two levels up
dotenv_path = os.path.join(os.path.dirname(__file__), '..', '..', '.env')
load_dotenv(dotenv_path=dotenv_path)
project_id = os.getenv("GOOGLE_CLOUD_PROJECT")
location = os.getenv("GOOGLE_CLOUD_LOCATION")
model_name = os.getenv("IMAGEN_MODEL")
client = genai.Client(
vertexai=True,
project=project_id,
location=location,
)
response = client.models.generate_images(
model="imagen-3.0-generate-002",
prompt=prompt,
config=types.GenerateImagesConfig(
number_of_images=1,
aspect_ratio="9:16",
safety_filter_level="block_low_and_above",
person_generation="allow_adult",
),
)
if not all([project_id, location, model_name]):
return "Error: Missing GOOGLE_CLOUD_PROJECT, GOOGLE_CLOUD_LOCATION, or IMAGEN_MODEL in .env file."
vertexai.init(project=project_id, location=location)
model = ImageGenerationModel.from_pretrained(model_name)
images = model.generate_images(
prompt=prompt,
number_of_images=1
)
if response.generated_images is None:
return "Error: No image was generated."
for generated_image in response.generated_images:
# Get the image bytes
image_bytes = generated_image.image.image_bytes
counter = str(tool_context.state.get("loop_iteration", 0))
artifact_name = f"generated_image_" + counter + ".png"
# Save as ADK artifact (optional, if still needed by other ADK components)
report_artifact = types.Part.from_bytes(
data=image_bytes, mime_type="image/png"
)
await tool_context.save_artifact(artifact_name, report_artifact)
logger.info(f"Image also saved as ADK artifact: {artifact_name}")
return {
"status": "success",
"message": f"Image generated . ADK artifact: {artifact_name}.",
"artifact_name": artifact_name,
}
except Exception as e:
error_message = f"An error occurred during image generation: {e}"
print(error_message)
return error_message
- প্রথমে ADK (এজেন্ট ডেভেলপমেন্ট কিট) সার্ভারটি রিস্টার্ট করুন। যে টার্মিনাল থেকে আপনি ADK (এজেন্ট ডেভেলপমেন্ট কিট) সার্ভারটি চালু করেছিলেন, সেখানে যান এবং সার্ভারটি তখনও চালু থাকলে তা বন্ধ করতে CTRL+C চাপুন । সার্ভারটি পুনরায় চালু করতে নিম্নলিখিত কমান্ডটি চালান।
#make sure you are in the right folder.
cd ~/adkui
#start the server
adk web
- স্ক্রিনে প্রদর্শিত ইউআরএল-এর (যেমন, http://localhost:8000 ) উপর Ctrl+Click করুন। ব্রাউজার ট্যাবে ADK (Agent Development Kit) GUI প্রদর্শিত হবে।
- ADK (এজেন্ট ডেভেলপমেন্ট কিট) UI ট্যাবে, এজেন্ট তালিকা থেকে Agent2 নির্বাচন করুন এবং সম্পাদনা বোতাম (পেন আইকন) টিপুন। ADK (এজেন্ট ডেভেলপমেন্ট কিট) ভিজ্যুয়াল এডিটরে পরিবর্তনগুলি স্থায়ী করতে সেভ বোতামে ক্লিক করুন।
- এখন আমরা নতুন এজেন্টটি পরীক্ষা করতে পারি।
- ADK (এজেন্ট ডেভেলপমেন্ট কিট) UI চ্যাট ইন্টারফেসে নিম্নলিখিত প্রম্পটটি লিখুন। আপনি অন্যান্য প্রম্পটও চেষ্টা করতে পারেন। আপনি চিত্র ২২-এ দেখানো ফলাফল দেখতে পাবেন।
Create an image of a cat

চিত্র ২২: ADK UI চ্যাট ইন্টারফেস
১০. একটি ওয়ার্কফ্লো এজেন্ট তৈরি করুন
পূর্ববর্তী ধাপে একটি সাব-এজেন্ট এবং বিশেষায়িত ইমেজ তৈরির টুলসহ একটি এজেন্ট তৈরি করা হলেও, এই পর্যায়ে এজেন্টের সক্ষমতা পরিমার্জনের উপর মনোযোগ দেওয়া হয়েছে। ইমেজ তৈরির আগে ব্যবহারকারীর প্রাথমিক প্রম্পটটি অপ্টিমাইজ করা নিশ্চিত করার মাধ্যমে আমরা প্রক্রিয়াটিকে আরও উন্নত করব। এটি অর্জন করতে, নিম্নলিখিত দুই-ধাপের ওয়ার্কফ্লোটি পরিচালনা করার জন্য রুট এজেন্টের সাথে একটি সিকোয়েনশিয়াল এজেন্টকে একীভূত করা হবে:
- রুট এজেন্টের কাছ থেকে প্রম্পটটি গ্রহণ করুন এবং প্রম্পটটির উন্নয়ন সাধন করুন।
- IMAGEN ব্যবহার করে চূড়ান্ত ছবিটি তৈরি করার জন্য পরিমার্জিত প্রম্পটটি ইমেজ ক্রিয়েটর এজেন্টের কাছে ফরোয়ার্ড করুন।
- প্রথমে ADK (এজেন্ট ডেভেলপমেন্ট কিট) সার্ভারটি রিস্টার্ট করুন। যে টার্মিনাল থেকে আপনি ADK (এজেন্ট ডেভেলপমেন্ট কিট) সার্ভারটি চালু করেছিলেন, সেখানে যান এবং সার্ভারটি তখনও চালু থাকলে তা বন্ধ করতে CTRL+C চাপুন । সার্ভারটি পুনরায় চালু করতে নিম্নলিখিত কমান্ডটি চালান।
#make sure you are in the right folder.
cd ~/adkui
#start the server
adk web
- স্ক্রিনে প্রদর্শিত ইউআরএল-এর (যেমন, http://localhost:8000 ) উপর Ctrl+Click করুন। ব্রাউজার ট্যাবে ADK (Agent Development Kit) GUI প্রদর্শিত হবে।
- এজেন্ট সিলেক্টর থেকে এজেন্ট২ নির্বাচন করুন এবং এডিট বাটনে (পেন আইকন) ক্লিক করুন।
- Agent2 (রুট এজেন্ট) -এ ক্লিক করুন এবং সাব এজেন্ট মেনুর পাশে থাকা "+" বোতামে ক্লিক করুন। এরপর অপশনের তালিকা থেকে সিকোয়েনশিয়াল এজেন্ট- এ ক্লিক করুন।
- আপনাকে এজেন্ট কাঠামোটি চিত্র ২৩- এ দেখানোটির মতো দেখতে হবে।

চিত্র ২৩: অনুক্রমিক এজেন্ট কাঠামো
- Now we will add the first agent to the Sequential Agent which will act as a prompt enhancer. To do So Click on the Add sub-agent Button inside the SequentialAgent box and Click LLM Agent
- আমাদের অনুক্রমে আরও একজন এজেন্ট যোগ করতে হবে, তাই আরও একজন এলএলএম এজেন্ট যোগ করার জন্য ধাপ ৬ পুনরাবৃত্তি করুন ( + বোতাম টিপুন এবং LLMAgent নির্বাচন করুন)।
- Click on sub_agent_4 and add a new Tool by clicking on the "+" icon next to the Tools on the Left Pane. Click " Function tool " from the options. On the DialogBox name the tool, Agent2.image_creation_tool.create_image and press "Create".
- এখন আমরা sub_agent_1-কে ডিলিট করতে পারি, কারণ এটিকে আরও উন্নত sub_agent_2 দ্বারা প্রতিস্থাপন করা হয়েছে। এটি করার জন্য, ডায়াগ্রামে sub_agent_1- এর ডান পাশে থাকা ডিলিট বাটনে ক্লিক করুন।

চিত্র ২৪: sub_agent_1 মুছে ফেলুন। ১০. আমাদের এজেন্ট কাঠামোটি চিত্র ২৫-এর মতো দেখাবে।

চিত্র ২৫: উন্নত এজেন্টের চূড়ান্ত কাঠামো
- sub_agent_3-এ ক্লিক করুন এবং নির্দেশাবলীতে নিম্নলিখিতগুলি লিখুন।
Act as a professional AI Image Prompt Engineer. I will provide you
with a basic idea for an image. Your job is to expand my idea into
a detailed, high-quality prompt for models like Imagen.
For every input, output the following structure:
1. **Optimized Prompt**: A vivid, descriptive paragraph including
subject, background, lighting, and textures.
2. **Style & Medium**: Specify if it is photorealistic, digital art,
oil painting, etc.
3. **Camera & Lighting**: Define the lens (e.g., 85mm), angle,
and light quality (e.g., volumetric, golden hour).
Guidelines: Use sensory language, avoid buzzwords like 'photorealistic'
unless necessary, and focus on specific artistic descriptors.
Once the prompt is created send the prompt to the
- sub_agent_4- এর উপর ক্লিক করুন। নির্দেশনাটি নিম্নোক্তভাবে পরিবর্তন করুন।
You are an agent that takes instructions about an image and can generate the image using the create_image tool.
- সেভ বোতামে ক্লিক করুন
- ক্লাউড শেল এডিটর এক্সপ্লোরার প্যানে যান এবং এজেন্ট yaml ফাইলগুলো খুলুন। এজেন্ট ফাইলগুলো নিচের মতো দেখতে হবে।
root_agent.yaml
name: Agent2
model: gemini-2.5-flash
agent_class: LlmAgent
instruction: You are an agent that takes image creation instruction from the
user and passes it to your sub agent
sub_agents:
- config_path: ./sub_agent_2.yaml
tools: []
sub_agent_2.yaml
name: sub_agent_2
agent_class: SequentialAgent
sub_agents:
- config_path: ./sub_agent_3.yaml
- config_path: ./sub_agent_4.yaml
sub_agent_3.yaml
name: sub_agent_3
model: gemini-2.5-flash
agent_class: LlmAgent
instruction: |
Act as a professional AI Image Prompt Engineer. I will provide you with a
basic idea for an image. Your job is to expand my idea into a detailed,
high-quality prompt for models like Imagen.
For every input, output the following structure: 1. **Optimized Prompt**: A
vivid, descriptive paragraph including subject, background, lighting, and
textures. 2. **Style & Medium**: Specify if it is photorealistic, digital
art, oil painting, etc. 3. **Camera & Lighting**: Define the lens (e.g.,
85mm), angle, and light quality (e.g., volumetric, golden hour).
Guidelines: Use sensory language, avoid buzzwords like
'photorealistic' unless necessary, and focus on specific artistic
descriptors. Once the prompt is created send the prompt to the
sub_agents: []
tools: []
sub_agent_4.yaml
name: sub_agent_4
model: gemini-2.5-flash
agent_class: LlmAgent
instruction: You are an agent that takes instructions about an image and
generate the image using the create_image tool.
sub_agents: []
tools:
- name: Agent2.image_creation_tool.create_image
- এবার এটা পরীক্ষা করা যাক।
- First restart the ADK (Agent Development Kit) Server. Go to the terminal where you started the ADK (Agent Development Kit) server and press CTRL+C to shutdown the server if it's still running. Execute the following to start the server again.
#make sure you are in the right folder.
cd ~/adkui
#start the server
adk web
- স্ক্রিনে প্রদর্শিত ইউআরএল-এর (যেমন, http://localhost:8000 ) উপর Ctrl+Click করুন। ব্রাউজার ট্যাবে ADK (Agent Development Kit) GUI প্রদর্শিত হবে।
- এজেন্ট তালিকা থেকে এজেন্ট২ নির্বাচন করুন। এবং নিম্নলিখিত নির্দেশাবলী প্রবেশ করান।
Create an image of a Cat
- এজেন্টটি কাজ করার সময় আপনি ক্লাউড শেল এডিটরের টার্মিনালে দেখতে পারেন যে ব্যাকগ্রাউন্ডে কী ঘটছে। চূড়ান্ত ফলাফলটি চিত্র ২৬-এর মতো দেখতে হওয়া উচিত।

চিত্র ২৬: এজেন্টটির পরীক্ষা
১১. এজেন্ট বিল্ডার অ্যাসিস্ট্যান্ট ব্যবহার করে একজন এজেন্ট তৈরি করুন।
এজেন্ট বিল্ডার অ্যাসিস্ট্যান্ট হলো ADK ভিজ্যুয়াল বিল্ডারের একটি অংশ, যা একটি সহজ চ্যাট ইন্টারফেসে প্রম্পটের মাধ্যমে বিভিন্ন স্তরের জটিলতা সহ ইন্টারেক্টিভভাবে এজেন্ট তৈরি করতে সক্ষম করে। ADK ভিজ্যুয়াল বিল্ডার ব্যবহার করে, আপনি আপনার তৈরি করা এজেন্টগুলোর উপর তাৎক্ষণিক ভিজ্যুয়াল ফিডব্যাক পেতে পারেন। এই ল্যাবে, আমরা এমন একটি এজেন্ট তৈরি করব যা ব্যবহারকারীর অনুরোধ থেকে একটি HTML কমিক বই তৈরি করতে সক্ষম। ব্যবহারকারীরা "হ্যানসেল এবং গ্রেটেল সম্পর্কে একটি কমিক বই তৈরি করুন"-এর মতো একটি সহজ প্রম্পট দিতে পারেন, অথবা তারা একটি সম্পূর্ণ গল্পও ইনপুট করতে পারেন। এরপর এজেন্টটি আখ্যানটি বিশ্লেষণ করবে, সেটিকে একাধিক প্যানেলে বিভক্ত করবে এবং কমিকের ভিজ্যুয়াল তৈরি করতে ন্যানোবানানা ব্যবহার করবে, এবং অবশেষে ফলাফলটিকে একটি HTML ফরম্যাটে প্যাকেজ করবে।

চিত্র ২৭: এজেন্ট বিল্ডার অ্যাসিস্ট্যান্ট UI
চলুন শুরু করা যাক!
- প্রথমে ADK (এজেন্ট ডেভেলপমেন্ট কিট) সার্ভারটি রিস্টার্ট করুন। যে টার্মিনাল থেকে আপনি ADK (এজেন্ট ডেভেলপমেন্ট কিট) সার্ভারটি চালু করেছিলেন, সেখানে যান এবং সার্ভারটি তখনও চালু থাকলে তা বন্ধ করতে CTRL+C চাপুন । সার্ভারটি পুনরায় চালু করতে নিম্নলিখিত কমান্ডটি চালান।
#make sure you are in the right folder.
cd ~/adkui
#start the server
adk web
- স্ক্রিনে প্রদর্শিত ইউআরএল-এর (যেমন, http://localhost:8000 ) উপর Ctrl+Click করুন। ব্রাউজার ট্যাবে ADK (Agent Development Kit) GUI প্রদর্শিত হবে।
- ADK (এজেন্ট ডেভেলপমেন্ট কিট) GUI-তে নতুন এজেন্ট তৈরি করতে "+" বোতামে ক্লিক করুন।
- ডায়ালগ বক্সে " Agent3 " লিখুন এবং " Create " বোতামে ক্লিক করুন।

চিত্র ২৮: নতুন এজেন্ট এজেন্ট৩ তৈরি করুন
- ডানদিকের অ্যাসিস্ট্যান্ট প্যানে নিম্নলিখিত প্রম্পটটি লিখুন। নিচের প্রম্পটটিতে একটি HTML ভিত্তিক এজেন্ট সিস্টেম তৈরি করার জন্য প্রয়োজনীয় সমস্ত নির্দেশাবলী রয়েছে।
System Goal: You are the Studio Director (Root Agent). Your objective is to manage a linear pipeline of four ADK Sequential Agents to transform a user's seed idea into a fully rendered, responsive HTML5 comic book.
0. Root Agent: The Studio Director
Role: Orchestrator and State Manager.
Logic: Receives the user's initial request. It initializes the workflow and ensures the output of each Sub-Agent is passed as the context for the next. It monitors the sequence to ensure no steps are skipped. Make sure the query explicitly mentions "Create me a comic of ..." if it's just a general question or prompt just answer the question.
1. Sub-Agent: The Scripting Agent (Sequential Step 1)
Role: Narrative & Character Architect.
Input: Seed idea from Root Agent.
Logic: 1. Create a Character Manifest: Define 3 specific, unchangeable visual identifiers
for every character (e.g., "Gretel: Blue neon hair ribbons, silver apron,
glowing boots").
2. Expand the seed idea into a coherent narrative arc.
Output: A narrative script and a mandatory character visual guide.
2. Sub-Agent: The Panelization Agent (Sequential Step 2)
Role: Cinematographer & Storyboarder.
Input: Script and Character Manifest from Step 1.
Logic:
1. Divide the script into exactly X panels (User-defined or default to 8).
2. For each panel, define a specific composition (e.g., "Panel 1:
Wide shot of the gingerbread house").
Output: A structured list of exactly X panel descriptions.
3. Sub-Agent: The Image Synthesis Agent (Sequential Step 3)
Role: Technical Artist & Asset Generator.
Input: The structured list of panel descriptions from Step 2.
Logic:
1. Iterative Generation: You must execute the "generate_image" tool in
"image_generation.py" file
(Nano Banana) individually for each panel defined in Step 2.
2. Prompt Engineering: For every panel, translate the description into a
Nano Banana prompt, strictly enforcing the character identifiers
(e.g., the "blue neon ribbons") and the global style: "vibrant comic book style,
heavy ink lines, cel-shaded, 4k." . Make sure that the necessary speech bubbles
are present in the image representing the dialogue.
3. Mapping: Associate each generated image URL with its corresponding panel
number and dialogue.
Output: A complete gallery of X images mapped to their respective panel data.
4. Sub-Agent: The Assembly Agent (Sequential Step 4)
Role: Frontend Developer.
Input: The mapped images and panel text from Step 3.
Logic:
1. Write a clean, responsive HTML5/CSS3 file that shows the comic. The comic should be
Scrollable with image on the top and the description below the image.
2. Use "write_comic_html" tool in file_writer.py to write the created html file in
the "output" folder.
4. In the "write_comic_html" tool add logic to copy the images folder to the
output folder so that the images in the html file are actually visible when
the user opens the html file.
Output: A final, production-ready HTML code block.
- এজেন্ট আপনাকে ব্যবহার করার জন্য মডেলটি ইনপুট করতে বলতে পারে, সেক্ষেত্রে প্রদত্ত অপশন থেকে gemini-2.5-pro লিখুন।
চিত্র ২৯: ব্যবহৃতব্য মডেল প্রবেশ করানোর জন্য অনুরোধ করা হলে gemini-2.5-pro প্রবেশ করান।
- সহকারী পরিকল্পনাটি নিয়ে আসতে পারেন এবং এগিয়ে যাওয়া ঠিক হবে কিনা তা নিশ্চিত করতে আপনাকে জিজ্ঞাসা করতে পারেন। পরিকল্পনাটি দেখে নিন এবং "OK" টাইপ করে "Enter" চাপুন।
চিত্র ৩০: পরিকল্পনাটি ঠিক মনে হলে OK লিখুন। ৮. অ্যাসিস্ট্যান্টের কাজ শেষ হলে আপনি চিত্র ৩১-এ দেখানো এজেন্ট কাঠামোটি দেখতে পাবেন।
চিত্র ৩১: এজেন্ট বিল্ডার অ্যাসিস্ট্যান্ট দ্বারা তৈরি এজেন্ট। ৯. image_synthesis_agent (আপনার দেওয়া নামটি ভিন্ন হতে পারে) এর ভিতরে "Agent3.tools.image_generation.gene..." টুলটিতে ক্লিক করুন। যদি টুলের নামের শেষ অংশটি image_generation.generate_image না হয়, তবে এটিকে image_generation.generate_image এ পরিবর্তন করুন। যদি নামটি আগে থেকেই সেট করা থাকে, তবে নামটি পরিবর্তন করার প্রয়োজন নেই। এটি সংরক্ষণ করতে "Save" বোতামটি চাপুন।
চিত্র ৩২: টুলটির নাম পরিবর্তন করে image_generation.generate_image করুন এবং Save চাপুন।
- assembly_agent-এর ভিতরে (আপনার এজেন্টের নাম ভিন্ন হতে পারে), **Agent3.tools.file_writer.write_comic_...** টুলটিতে ক্লিক করুন। যদি টুলের নামের শেষ অংশটি **file_writer.write_comic_html** না হয়, তবে এটিকে **file_writer.write_comic_html**-এ পরিবর্তন করুন।
চিত্র ৩৩: টুলের নাম পরিবর্তন করে file_writer.write_comic_html করুন। ১১. নতুন তৈরি করা এজেন্টটি সংরক্ষণ করতে বাম প্যানেলের নীচে বাম দিকে থাকা সেভ বোতামটি চাপুন। ১২. ক্লাউড শেল এডিটর এক্সপ্লোরার প্যানে, Agent3 ফোল্ডারটি এক্সপ্যান্ড করুন এবং Agent3/ ফোল্ডারের ভিতরে tools ফোল্ডারটি থাকা উচিত। Agent3/tools/file_writer.py ফাইলটি খুলতে ক্লিক করুন এবং Agent3/tools/file_writer.py ফাইলের বিষয়বস্তু নিম্নলিখিত কোড দিয়ে প্রতিস্থাপন করুন। সংরক্ষণ করতে Ctrl+S চাপুন। দ্রষ্টব্য: যদিও এজেন্ট অ্যাসিস্ট্যান্ট ইতিমধ্যেই সঠিক কোড তৈরি করে থাকতে পারে, এই ল্যাবের জন্য আমরা পরীক্ষিত কোডটি ব্যবহার করব।
import os
import shutil
def write_comic_html(html_content: str, image_directory: str = "images") -> str:
"""
Writes the final HTML content to a file and copies the image assets.
Args:
html_content: A string containing the full HTML of the comic.
image_directory: The source directory where generated images are stored.
Returns:
A confirmation message indicating success or failure.
"""
output_dir = "output"
images_output_dir = os.path.join(output_dir, image_directory)
try:
# Create the main output directory
if not os.path.exists(output_dir):
os.makedirs(output_dir)
# Copy the entire image directory to the output folder
if os.path.exists(image_directory):
if os.path.exists(images_output_dir):
shutil.rmtree(images_output_dir) # Remove old images
shutil.copytree(image_directory, images_output_dir)
else:
return f"Error: Image directory '{image_directory}' not found."
# Write the HTML file
html_file_path = os.path.join(output_dir, "comic.html")
with open(html_file_path, "w") as f:
f.write(html_content)
return f"Successfully created comic at '{html_file_path}'"
except Exception as e:
return f"An error occurred: {e}"
- In the Cloud Shell Editor Explorer pane, Expand Agent3 folder and inside **Agent3/**folder there should be tools folder. Click Agent3/tools/image_generation.py to open it and replace the content of Agent3/tools/image_generation.py with the following code. Press Ctrl+S to save. Note: While the Agent assistant may have already created the correct code, for this lab we will use the tested code.
import time
import os
import io
import vertexai
from vertexai.preview.vision_models import ImageGenerationModel
from dotenv import load_dotenv
import uuid
from typing import Union
from datetime import datetime
from google import genai
from google.genai import types
from google.adk.tools import ToolContext
import logging
import asyncio
# Configure logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
# It's better to initialize the client once and reuse it.
# IMPORTANT: Your Google Cloud Project ID must be set as an environment variable
# for the client to authenticate correctly.
def edit_image(client, prompt: str, previous_image: str, model_id: str) -> Union[bytes, None]:
"""
Calls the model to edit an image based on a prompt.
Args:
prompt: The text prompt for image editing.
previous_image: The path to the image to be edited.
model_id: The model to use for the edit.
Returns:
The raw image data as bytes, or None if an error occurred.
"""
try:
with open(previous_image, "rb") as f:
image_bytes = f.read()
response = client.models.generate_content(
model=model_id,
contents=[
types.Part.from_bytes(
data=image_bytes,
mime_type="image/png", # Assuming PNG, adjust if necessary
),
prompt,
],
config=types.GenerateContentConfig(
response_modalities=['IMAGE'],
)
)
# Extract image data
for part in response.candidates[0].content.parts:
if part.inline_data:
return part.inline_data.data
logger.warning("Warning: No image data was generated for the edit.")
return None
except FileNotFoundError:
logger.error(f"Error: The file {previous_image} was not found.")
return None
except Exception as e:
logger.error(f"An error occurred during image editing: {e}")
return None
async def generate_image(tool_context: ToolContext, prompt: str, image_name: str, previous_image: str = None) -> dict:
"""
Generates or edits an image and saves it to the 'images/' directory.
If 'previous_image' is provided, it edits that image. Otherwise, it generates a new one.
Args:
prompt: The text prompt for the operation.
image_name: The desired name for the output image file (without extension).
previous_image: Optional path to an image to be edited.
Returns:
A confirmation message with the path to the saved image or an error message.
"""
load_dotenv()
project_id = os.environ.get("GOOGLE_CLOUD_PROJECT")
if not project_id:
return "Error: GOOGLE_CLOUD_PROJECT environment variable is not set."
try:
client = genai.Client(vertexai=True, project=project_id, location="global")
except Exception as e:
return f"Error: Failed to initialize genai.Client: {e}"
image_data = None
model_id = "gemini-3-pro-image-preview"
try:
if previous_image:
logger.info(f"Editing image: {previous_image}")
image_data = edit_image(
client=client,
prompt=prompt,
previous_image=previous_image,
model_id=model_id
)
else:
logger.info("Generating new image")
# Generate the image
response = client.models.generate_content(
model=model_id,
contents=prompt,
config=types.GenerateContentConfig(
response_modalities=['IMAGE'],
image_config=types.ImageConfig(aspect_ratio="16:9"),
),
)
# Check for errors
if response.candidates[0].finish_reason != types.FinishReason.STOP:
return f"Error: Image generation failed. Reason: {response.candidates[0].finish_reason}"
# Extract image data
for part in response.candidates[0].content.parts:
if part.inline_data:
image_data = part.inline_data.data
break
if not image_data:
return {"status": "error", "message": "No image data was generated.", "artifact_name": None}
# Create the images directory if it doesn't exist
output_dir = "images"
os.makedirs(output_dir, exist_ok=True)
# Save the image to file system
file_path = os.path.join(output_dir, f"{image_name}.png")
with open(file_path, "wb") as f:
f.write(image_data)
# Save as ADK artifact
counter = str(tool_context.state.get("loop_iteration", 0))
artifact_name = f"{image_name}_" + counter + ".png"
report_artifact = types.Part.from_bytes(data=image_data, mime_type="image/png")
await tool_context.save_artifact(artifact_name, report_artifact)
logger.info(f"Image also saved as ADK artifact: {artifact_name}")
return {
"status": "success",
"message": f"Image generated and saved to {file_path}. ADK artifact: {artifact_name}.",
"artifact_name": artifact_name,
}
except Exception as e:
return f"An error occurred: {e}"
- লেখকের পরিবেশে তৈরি চূড়ান্ত YAML ফাইলগুলো আপনার অবগতির জন্য নিচে দেওয়া হলো (অনুগ্রহ করে মনে রাখবেন যে আপনার পরিবেশের ফাইলগুলো কিছুটা ভিন্ন হতে পারে)। অনুগ্রহ করে নিশ্চিত করুন যে আপনার এজেন্টের YAML কাঠামোটি ADK ভিজ্যুয়াল বিল্ডারে প্রদর্শিত লেআউটের সাথে মিলে যায়।
root_agent.yamlname: studio_director
model: gemini-2.5-pro
agent_class: LlmAgent
description: The Studio Director who manages the comic creation pipeline.
instruction: >
You are the Studio Director. Your objective is to manage a linear pipeline of
four sequential agents to transform a user's seed idea into a fully rendered,
responsive HTML5 comic book.
Your role is to be the primary orchestrator and state manager. You will
receive the user's initial request.
**Workflow:**
1. If the user's prompt starts with "Create me a comic of ...", you must
delegate the task to your sub-agent to begin the comic creation pipeline.
2. If the user asks a general question or provides a prompt that does not
explicitly ask to create a comic, you must answer the question directly
without triggering the comic creation pipeline.
3. Monitor the sequence to ensure no steps are skipped. Ensure the output of
each Sub-Agent is passed as the context for the next.
sub_agents:
- config_path: ./comic_pipeline.yaml
tools: []
comic_pipline.yaml
name: comic_pipeline
agent_class: SequentialAgent
description: A sequential pipeline of agents to create a comic book.
sub_agents:
- config_path: ./scripting_agent.yaml
- config_path: ./panelization_agent.yaml
- config_path: ./image_synthesis_agent.yaml
- config_path: ./assembly_agent.yaml
scripting_agent.yamlname: scripting_agent
model: gemini-2.5-pro
agent_class: LlmAgent
description: Narrative & Character Architect.
instruction: >
You are the Scripting Agent, a Narrative & Character Architect.
Your input is a seed idea for a comic.
**Your Logic:**
1. **Create a Character Manifest:** You must define exactly 3 specific,
unchangeable visual identifiers for every character. For example: "Gretel:
Blue neon hair ribbons, silver apron, glowing boots". This is mandatory.
2. **Expand the Narrative:** Expand the seed idea into a coherent narrative
arc with dialogue.
**Output:**
You must output a JSON object containing:
- "narrative_script": A detailed script with scenes and dialogue.
- "character_manifest": The mandatory character visual guide.
sub_agents: []
tools: []
panelization_agent.yamlname: panelization_agent
model: gemini-2.5-pro
agent_class: LlmAgent
description: Cinematographer & Storyboarder.
instruction: >
You are the Panelization Agent, a Cinematographer & Storyboarder.
Your input is a narrative script and a character manifest.
**Your Logic:**
1. **Divide the Script:** Divide the script into a specific number of panels.
The user may define this number, or you should default to 8 panels.
2. **Define Composition:** For each panel, you must define a specific
composition, camera shot (e.g., "Wide shot", "Close-up"), and the dialogue for
that panel.
**Output:**
You must output a JSON object containing a structured list of exactly X panel
descriptions, where X is the number of panels. Each item in the list should
have "panel_number", "composition_description", and "dialogue".
sub_agents: []
tools: []
image_synthesis_agent.yaml
name: image_synthesis_agent
model: gemini-2.5-pro
agent_class: LlmAgent
description: Technical Artist & Asset Generator.
instruction: >
You are the Image Synthesis Agent, a Technical Artist & Asset Generator.
Your input is a structured list of panel descriptions.
**Your Logic:**
1. **Iterate and Generate:** You must iterate through each panel description
provided in the input. For each panel, you will execute the `generate_image`
tool.
2. **Construct Prompts:** For each panel, you will construct a detailed
prompt for the image generation tool. This prompt must strictly enforce the
character visual identifiers from the manifest and include the global style:
"vibrant comic book style, heavy ink lines, cel-shaded, 4k". The prompt must
also describe the composition and include a request for speech bubbles to
contain the dialogue.
3. **Map Output:** You must associate each generated image URL with its
corresponding panel number and dialogue.
**Output:**
You must output a JSON object containing a complete gallery of all generated
images, mapped to their respective panel data (panel_number, dialogue,
image_url).
sub_agents: []
tools:
- name: Agent3.tools.image_generation.generate_image
assembly_agent.yamlname: assembly_agent
model: gemini-2.5-pro
agent_class: LlmAgent
description: Frontend Developer for comic book assembly.
instruction: >
You are the Assembly Agent, a Frontend Developer.
Your input is the mapped gallery of images and panel data.
**Your Logic:**
1. **Generate HTML:** You will write a clean, responsive HTML5/CSS3 file to
display the comic. The comic must be vertically scrollable, with each panel
displaying its image on top and the corresponding dialogue or description
below it.
2. **Write File:** You must use the `write_comic_html` tool to save the
generated HTML to a file named `comic.html` in the `output/` folder.
3. Pass the list of image URLs to the tool so it can handle the image assets
correctly.
**Output:**
You will output a confirmation message indicating the path to the final HTML
file.
sub_agents: []
tools:
- name: Agent3.tools.file_writer.write_comic_html
- ADK (এজেন্ট ডেভেলপমেন্ট কিট) UI ট্যাবে যান, " Agent3 " নির্বাচন করুন এবং সম্পাদনা বোতামে ("কলম আইকন") ক্লিক করুন।
- স্ক্রিনের নিচের বাম দিকে থাকা সেভ বাটনে ক্লিক করুন। এর মাধ্যমে মূল এজেন্টে আপনার করা সমস্ত কোড পরিবর্তন স্থায়ী হবে।
- এখন আমরা আমাদের এজেন্টের পরীক্ষা শুরু করতে পারি!
- বর্তমান ADK (এজেন্ট ডেভেলপমেন্ট কিট) UI ট্যাবটি বন্ধ করুন এবং ক্লাউড শেল এডিটর ট্যাবে ফিরে যান।
- টার্মিনালের ক্লাউড শেল এডিটর ট্যাবের ভেতরে, প্রথমে ADK (এজেন্ট ডেভেলপমেন্ট কিট) সার্ভারটি রিস্টার্ট করুন। যে টার্মিনাল থেকে আপনি ADK (এজেন্ট ডেভেলপমেন্ট কিট) সার্ভারটি চালু করেছিলেন, সেখানে যান এবং সার্ভারটি তখনও চালু থাকলে তা বন্ধ করতে CTRL+C চাপুন । সার্ভারটি পুনরায় চালু করতে নিম্নলিখিত কমান্ডটি চালান।
#make sure you are in the right folder.
cd ~/adkui
#start the server
adk web
- স্ক্রিনে প্রদর্শিত ইউআরএল-এর (যেমন, http://localhost:8000 ) উপর Ctrl+Click করুন। ব্রাউজার ট্যাবে ADK (Agent Development Kit) GUI প্রদর্শিত হবে।
- এজেন্টদের তালিকা থেকে এজেন্ট৩ নির্বাচন করুন।
- নিম্নলিখিত প্রম্পটটি প্রবেশ করান
Create a Comic Book based on the following story,
Title: The Story of Momotaro
The story of Momotaro (Peach Boy) is one of Japan's most famous and beloved folktales. It is a classic "hero's journey" that emphasizes the virtues of courage, filial piety, and teamwork.
The Miraculous Birth
Long, long ago, in a small village in rural Japan, lived an elderly couple. They were hardworking and kind, but they were sad because they had never been blessed with children.
One morning, while the old woman was washing clothes by the river, she saw a magnificent, giant peach floating downstream. It was larger than any peach she had ever seen. With great effort, she pulled it from the water and brought it home to her husband for their dinner.
As they prepared to cut the fruit open, the peach suddenly split in half on its own. To their astonishment, a healthy, beautiful baby boy stepped out from the pit.
"Don't be afraid," the child said. "The Heavens have sent me to be your son."
Overjoyed, the couple named him Momotaro (Momo meaning peach, and Taro being a common name for an eldest son).
The Call to Adventure
Momotaro grew up to be stronger and kinder than any other boy in the village. During this time, the village lived in fear of the Oni—ogres and demons who lived on a distant island called Onigashima. These Oni would often raid the mainland, stealing treasures and kidnapping villagers.
When Momotaro reached young adulthood, he approached his parents with a request. "I must go to Onigashima," he declared. "I will defeat the Oni and bring back the stolen treasures to help our people."
Though they were worried, his parents were proud. As a parting gift, the old woman prepared Kibi-dango (special millet dumplings), which were said to provide the strength of a hundred men.
Gathering Allies
Momotaro set off on his journey toward the sea. Along the way, he met three distinct animals:
The Spotted Dog: The dog growled at first, but Momotaro offered him one of his Kibi-dango. The dog, tasting the magical dumpling, immediately swore his loyalty.
The Monkey: Further down the road, a monkey joined the group in exchange for a dumpling, though he and the dog bickered constantly.
The Pheasant: Finally, a pheasant flew down from the sky. After receiving a piece of the Kibi-dango, the bird joined the team as their aerial scout.
Momotaro used his leadership to ensure the three animals worked together despite their differences, teaching them that unity was their greatest strength.
The Battle of Onigashima
The group reached the coast, built a boat, and sailed to the dark, craggy shores of Onigashima. The island was guarded by a massive iron gate.
The Pheasant flew over the walls to distract the Oni and peck at their eyes.
The Monkey climbed the walls and unbolted the Great Gate from the inside.
The Dog and Momotaro charged in, using their immense strength to overpower the demons.
The Oni were caught off guard by the coordinated attack. After a fierce battle, the King of the Oni fell to his knees before Momotaro, begging for mercy. He promised to never trouble the villagers again and surrendered all the stolen gold, jewels, and precious silks.
The Triumphant Return
Momotaro and his three companions loaded the treasure onto their boat and returned to the village. The entire town celebrated their homecoming.
Momotaro used the wealth to ensure his elderly parents lived the rest of their lives in comfort and peace. He remained in the village as a legendary protector, and his story was passed down for generations as a reminder that bravery and cooperation can overcome even the greatest evils.
- এজেন্টটি কাজ করার সময় আপনি ক্লাউড শেল এডিটর টার্মিনালে ইভেন্টগুলো দেখতে পারবেন।
- সবগুলো ছবি তৈরি হতে কিছুটা সময় লাগতে পারে, তাই অনুগ্রহ করে ধৈর্য ধরুন অথবা চট করে এক কাপ কফি খেয়ে নিন! ছবি তৈরি হওয়া শুরু হলে আপনি নীচের মতো গল্প-সম্পর্কিত ছবিগুলো দেখতে পাবেন।

চিত্র ৩৪: কমিক স্ট্রিপ হিসেবে মোমোতারোর গল্প। ২৫. সবকিছু ঠিকঠাক চললে তৈরি হওয়া html ফাইলটি html ফোল্ডারে সেভ হবে। আপনি যদি এজেন্টের কোনো উন্নতি করতে চান, তাহলে এজেন্ট অ্যাসিস্ট্যান্টের কাছে ফিরে গিয়ে তাকে আরও পরিবর্তন করতে বলতে পারেন!

চিত্র ৩৫: আউটপুট ফোল্ডারের বিষয়বস্তু
- যদি ২৫ নং ধাপটি সঠিকভাবে সম্পন্ন হয় এবং আপনি আউটপুট ফোল্ডারে comic.html ফাইলটি পান, তবে এটি পরীক্ষা করার জন্য আপনি নিম্নলিখিত ধাপগুলো অনুসরণ করতে পারেন। প্রথমেই , Cloud Shell Editor- এর প্রধান মেনু থেকে Terminal>New Terminal-এ ক্লিক করে একটি নতুন টার্মিনাল খুলুন। এতে একটি নতুন টার্মিনাল খুলে যাবে।
#go to the project folder
cd ~/adkui
#activate python virtual environment
source .venv/bin/activate
#Go to the output folder
cd ~/adkui/output
#start local web server
python -m http.server 8080
- http://0.0.0.0:8080- এ Ctrl+Click করুন

চিত্র ৩৬: স্থানীয় ওয়েব সার্ভার চালানো
- ফোল্ডারের বিষয়বস্তু ব্রাউজার ট্যাবে প্রদর্শিত হবে। html ফাইলটিতে (যেমন comic.html) ক্লিক করুন। কমিকটি নীচের মতো প্রদর্শিত হবে (আপনার আউটপুট কিছুটা ভিন্ন হতে পারে)।

চিত্র ৩৭: লোকালহোস্টে চলছে
১২. পরিষ্কার করুন
এবার আমরা যা তৈরি করেছি তা পরিষ্কার করে ফেলি।
- এইমাত্র তৈরি করা ক্লাউড রান অ্যাপটি ডিলিট করুন। ক্লাউড রান -এ প্রবেশ করে সেখানে যান। আপনি আগের ধাপে তৈরি করা অ্যাপটি দেখতে পাবেন। অ্যাপটির পাশের বক্সে টিক চিহ্ন দিন এবং ডিলিট বোতামে ক্লিক করুন।
চিত্র ৩৮: ক্লাউড রান অ্যাপ ডিলিট করা ২. ক্লাউড শেল-এ থাকা ফাইলগুলো ডিলিট করুন
#Execute the following to delete the files
cd ~
rm -R ~/adkui
১৩. উপসংহার
অভিনন্দন! আপনি বিল্ট-ইন ADK ভিজ্যুয়াল বিল্ডার ব্যবহার করে সফলভাবে ADK (এজেন্ট ডেভেলপমেন্ট কিট) এজেন্ট তৈরি করেছেন। আপনি ক্লাউড রান- এ অ্যাপ্লিকেশনটি কীভাবে ডেপ্লয় করতে হয়, তাও শিখেছেন। এটি একটি উল্লেখযোগ্য অর্জন যা একটি আধুনিক ক্লাউড-নেটিভ অ্যাপ্লিকেশনের মূল জীবনচক্রকে অন্তর্ভুক্ত করে এবং আপনার নিজস্ব জটিল এজেন্টিক সিস্টেম ডেপ্লয় করার জন্য একটি মজবুত ভিত্তি প্রদান করে।
পুনরালোচনা
এই ল্যাবে আপনি শিখেছেন:
- ADK ভিজ্যুয়াল বিল্ডার ব্যবহার করে মাল্টি এজেন্ট অ্যাপ্লিকেশন তৈরি করুন
- অ্যাপ্লিকেশনটি ক্লাউড রানে স্থাপন করুন
দরকারী সম্পদ