কম্পিউটার ইউজ টুলটি আপনাকে ব্রাউজার, মোবাইল এবং ডেস্কটপ কন্ট্রোল এজেন্ট তৈরি করতে দেয়, যা বিভিন্ন কাজের সাথে ইন্টারঅ্যাক্ট করে এবং সেগুলোকে স্বয়ংক্রিয় করে তোলে। স্ক্রিনশট ব্যবহার করে, মডেলটি একটি কম্পিউটার স্ক্রিন "দেখতে" পারে এবং মাউস ক্লিক ও কিবোর্ড ইনপুটের মতো নির্দিষ্ট UI অ্যাকশন তৈরি করে "কাজ" করতে পারে। ফাংশন কলিংয়ের মতোই, কম্পিউটার ইউজ অ্যাকশনগুলো গ্রহণ ও কার্যকর করার জন্য আপনাকে ক্লায়েন্ট-সাইড এক্সিকিউশন এনভায়রনমেন্ট ইমপ্লিমেন্ট করতে হবে।
কম্পিউটারে ব্যবহারের জন্য জেমিনি ৩.৫ ফ্ল্যাশ হলো প্রস্তাবিত মডেল এবং এটি বেশ কিছু নতুন সক্ষমতা নিয়ে এসেছে:
- একাধিক পরিবেশ সমর্থন: ব্রাউজার, মোবাইল এবং ডেস্কটপ পরিবেশের জন্য এজেন্ট তৈরি করুন।
- ইনটেন্ট-সহ সুবিন্যস্ত অ্যাকশন: অ্যাকশনগুলোতে একটি
intentফিল্ড থাকে, যা প্রতিটি ধাপের পেছনের মডেলের যুক্তি ব্যাখ্যা করে। - কনফিগারযোগ্য সুরক্ষা নীতিমালা: অন্তর্নির্মিত নীতি বিভাগ এবং ওভাররাইডের মাধ্যমে সুরক্ষা আচরণকে সূক্ষ্মভাবে সমন্বয় করুন।
- প্রম্পট ইনজেকশন সনাক্তকরণ: লুকানো প্রতিকূল নির্দেশাবলী সনাক্ত করতে ঐচ্ছিক স্ক্রিনশট স্ক্যানিং ।
কম্পিউটার ব্যবহারের মাধ্যমে আপনি এমন এজেন্ট তৈরি করতে পারেন যা:
- ওয়েবসাইটে পুনরাবৃত্তিমূলক ডেটা এন্ট্রি বা ফর্ম পূরণ স্বয়ংক্রিয় করুন।
- ওয়েব অ্যাপ্লিকেশন এবং ইউজার ফ্লো-এর স্বয়ংক্রিয় টেস্টিং সম্পাদন করুন
- বিভিন্ন ওয়েবসাইটে গবেষণা করুন (যেমন, কোনো কিছু কেনার সিদ্ধান্ত নেওয়ার জন্য ই-কমার্স সাইট থেকে পণ্যের তথ্য, দাম এবং রিভিউ সংগ্রহ করা)।
ব্রাউজার পরিবেশে computer_use টুলটি সক্রিয় রেখে ক্লায়েন্ট ইনিশিয়ালাইজ করা এবং মডেলে একটি প্রম্পট পাঠানোর একটি সংক্ষিপ্ত উদাহরণ নিচে দেওয়া হলো:
পাইথন
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-3.5-flash",
input="Search for 'Gemini API' on Google.",
tools=[{"type": "computer_use", "environment": "browser"}]
)
print(interaction)
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from '@google/genai';
const ai = new GoogleGenAI();
const interaction = await ai.interactions.create({
model: 'gemini-3.5-flash',
input: "Search for 'Gemini API' on Google.",
tools: [{ type: "computer_use", environment: "browser" }]
});
console.log(interaction);
কম্পিউটার ব্যবহার কীভাবে কাজ করে
কম্পিউটার ইউজ মডেল ব্যবহার করে একটি এজেন্ট তৈরি করতে, আপনাকে আপনার অ্যাপ্লিকেশন এবং এপিআই-এর মধ্যে একটি নিরবচ্ছিন্ন লুপ স্থাপন করতে হবে। প্রতিটি ধাপে আপনার কোড যা করবে তা নিচে দেওয়া হলো:
- মডেলকে একটি অনুরোধ পাঠান
- আপনার অ্যাপ্লিকেশনটি একটি এপিআই অনুরোধ পাঠায়, যাতে কম্পিউটার ব্যবহারের টুল, আপনার কনফিগারেশন সেটিংস (যেমন টার্গেট এনভায়রনমেন্ট), ব্যবহারকারীর প্রম্পট এবং বর্তমান স্ক্রিনের একটি স্ক্রিনশট থাকে।
- নমুনা প্রতিক্রিয়া গ্রহণ করুন
- মডেলটি স্ক্রিন এবং প্রম্পট বিশ্লেষণ করে একটি প্রতিক্রিয়া ফেরত দেয়, যার মধ্যে একটি UI অ্যাকশন (যেমন ক্লিক, স্ক্রল বা কীস্ট্রোক) উপস্থাপনকারী একটি প্রস্তাবিত
function_callঅন্তর্ভুক্ত থাকে। - জেমিনি ৩.৫ ফ্ল্যাশ- এর ক্ষেত্রে, প্রতিক্রিয়াটিতে একটি যৌক্তিক
intentঅন্তর্ভুক্ত থাকে, যা ব্যাখ্যা করে কেন মডেলটি সেই কাজটি বেছে নিয়েছে। - লিগ্যাসি মডেলগুলির (যেমন
gemini-2.5-computer-use-preview-10-2025) ক্ষেত্রে, প্রতিক্রিয়ায় একটি অভ্যন্তরীণ সুরক্ষা সিস্টেম থেকে একটিsafety_decisionঅন্তর্ভুক্ত থাকতে পারে, যা অ্যাকশনটিকে সাধারণ/অনুমোদিত,require_confirmation(ব্যবহারকারীর অনুমোদনের প্রয়োজন), অথবা অবরুদ্ধ হিসাবে শ্রেণীবদ্ধ করে।
- মডেলটি স্ক্রিন এবং প্রম্পট বিশ্লেষণ করে একটি প্রতিক্রিয়া ফেরত দেয়, যার মধ্যে একটি UI অ্যাকশন (যেমন ক্লিক, স্ক্রল বা কীস্ট্রোক) উপস্থাপনকারী একটি প্রস্তাবিত
- প্রাপ্ত কাজটি সম্পাদন করুন
- যদি কাজটি করার অনুমতি থাকে (বা ব্যবহারকারী তা নিশ্চিত করেন), তাহলে আপনার ক্লায়েন্ট-সাইড কোড `
function_callটি পার্স করে, আপনার ভিউপোর্টের সাথে মেলানোর জন্য নর্মালাইজড কোঅর্ডিনেটগুলোকে স্কেল করে এবং অটোমেশন টুল (যেমন প্লেরাইট) ব্যবহার করে আপনার টার্গেট এনভায়রনমেন্টে কাজটি সম্পাদন করে। যদি কাজটি ব্লক করা থাকে, তবে আপনার ক্লায়েন্টের উচিত এক্সিকিউশন থামিয়ে দেওয়া বা বাধাটি সামাল দেওয়া।
- যদি কাজটি করার অনুমতি থাকে (বা ব্যবহারকারী তা নিশ্চিত করেন), তাহলে আপনার ক্লায়েন্ট-সাইড কোড `
- নতুন পরিবেশের অবস্থা ধারণ করুন
- কাজটি সম্পাদন শেষ হওয়ার পর, আপনার অ্যাপ্লিকেশনটি একটি নতুন স্ক্রিনশট নেয় এবং পরবর্তী পদক্ষেপের অনুরোধ করার জন্য `
function_resultএর মাধ্যমে সেটি মডেলে ফেরত পাঠায়।
- কাজটি সম্পাদন শেষ হওয়ার পর, আপনার অ্যাপ্লিকেশনটি একটি নতুন স্ক্রিনশট নেয় এবং পরবর্তী পদক্ষেপের অনুরোধ করার জন্য `
এই প্রক্রিয়াটি এরপর ধাপ ২ থেকে পুনরাবৃত্তি হয় এবং কাজটি সম্পন্ন বা সমাপ্ত না হওয়া পর্যন্ত মডেলের কাছ থেকে পরবর্তী পদক্ষেপের জন্য ক্রমাগত অনুরোধ করতে থাকে।

কম্পিউটার ব্যবহার কীভাবে বাস্তবায়ন করবেন
কম্পিউটার ব্যবহার টুল দিয়ে বিল্ড করার আগে আপনাকে যা যা সেট আপ করতে হবে:
- নিরাপদ এক্সিকিউশন এনভায়রনমেন্ট: আপনার এজেন্টকে হোস্ট সিস্টেম থেকে বিচ্ছিন্ন করতে এবং এর সম্ভাব্য প্রভাব সীমিত করতে একটি স্যান্ডবক্সড ভিএম বা কন্টেইনারে চালান। রেফারেন্স ইমপ্লিমেন্টেশনে একটি রেডি-টু-ইউজ ডকার-ভিত্তিক স্যান্ডবক্স অন্তর্ভুক্ত রয়েছে, যা আপনি শুরুর বিন্দু হিসেবে ব্যবহার করতে পারেন।
- ক্লায়েন্ট-সাইড অ্যাকশন হ্যান্ডলার: স্থানাঙ্ক সম্পাদন, টেক্সট টাইপ করা এবং স্ক্রিনশট নেওয়ার জন্য ক্লায়েন্ট-সাইড লজিক প্রয়োগ করুন।
নিচের উদাহরণগুলোতে এক্সিকিউশন এনভায়রনমেন্ট হিসেবে একটি ওয়েব ব্রাউজার এবং ক্লায়েন্ট-সাইড হ্যান্ডলার হিসেবে প্লেরাইট ব্যবহার করা হয়েছে।
০. প্লেরাইট সেট আপ করুন
প্রথমে, প্রয়োজনীয় প্যাকেজগুলো ইনস্টল করুন:
pip install google-genai playwright
playwright install chromium
তারপর, এক্সিকিউশনের জন্য একটি প্লেরাইট ব্রাউজার ইনস্ট্যান্স ইনিশিয়ালাইজ করুন:
from playwright.sync_api import sync_playwright
# 1. Configure screen dimensions for the target environment
SCREEN_WIDTH = 1440
SCREEN_HEIGHT = 900
# 2. Start the Playwright browser
# In production, utilize a sandboxed environment.
playwright = sync_playwright().start()
# Set headless=False to see the actions performed on your screen
browser = playwright.chromium.launch(headless=False)
# 3. Create a context and page with the specified dimensions
context = browser.new_context(
viewport={"width": SCREEN_WIDTH, "height": SCREEN_HEIGHT}
)
page = context.new_page()
# 4. Navigate to an initial page to start the task
page.goto("https://www.google.com")
# The 'page', 'SCREEN_WIDTH', and 'SCREEN_HEIGHT' variables
# will be used in the steps below.
১. মডেলকে একটি অনুরোধ পাঠান
ক্লায়েন্ট লাইব্রেরিটি ইনিশিয়ালাইজ করুন এবং কম্পিউটার ইউজ টুলটি কনফিগার করুন। উল্লেখ্য যে, অনুরোধ জানানোর সময় ডিসপ্লে সাইজ নির্দিষ্ট করার প্রয়োজন নেই; মডেলটি স্ক্রিনের উচ্চতা ও প্রস্থ অনুযায়ী স্কেল করা পিক্সেল স্থানাঙ্ক অনুমান করে।
জেমিনি ৩.৫ ফ্ল্যাশ (প্রস্তাবিত)
পাইথন
ব্রাউজার পরিবেশকে লক্ষ্য করে একটি অনুরোধ কনফিগার করতে google-genai পাইথন SDK (সংস্করণ 2.7.0 বা উচ্চতর) ব্যবহার করুন:
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model='gemini-3.5-flash',
input="Find a flight from SF to Hawaii on Jun 30th, coming back on Jul 6th",
tools=[
{
"type": "computer_use",
"environment": "browser",
"enable_prompt_injection_detection": True
}
]
)
print(interaction)
জাভাস্ক্রিপ্ট
ব্রাউজার পরিবেশকে লক্ষ্য করে একটি অনুরোধ কনফিগার করতে @google/genai Node.js SDK ব্যবহার করুন:
import { GoogleGenAI } from '@google/genai';
const ai = new GoogleGenAI();
const interaction = await ai.interactions.create({
model: 'gemini-3.5-flash',
input: "Find a flight from SF to Hawaii on Jun 30th, coming back on Jul 6th",
tools: [
{
type: "computer_use",
environment: "browser",
enable_prompt_injection_detection: true
}
]
});
console.log(interaction);
বিশ্রাম
অনুরোধ পাঠাতে `curl` ব্যবহার করুন:
curl -X POST \
"https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3.5-flash",
"input": "Find me a flight from SF to Hawaii on Jun 30th, coming back on Jul 6th. Start by navigating directly to flights.google.com",
"tools": [
{
"type": "computer_use",
"environment": "browser",
"enable_prompt_injection_detection": true
}
]
}'
জেমিনি ২.৫ (লেগ্যাসি)
পাইথন
from google import genai
client = genai.Client()
# Specify predefined functions to exclude (optional)
excluded_functions = ["drag_and_drop"]
interaction = client.interactions.create(
model='gemini-2.5-computer-use-preview-10-2025',
input="Search for highly rated smart fridges on Google Shopping.",
tools=[
{
"type": "computer_use",
"environment": "browser",
"excluded_predefined_functions": excluded_functions
}
]
)
print(interaction)
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from '@google/genai';
const ai = new GoogleGenAI();
// Specify predefined functions to exclude (optional)
const excludedFunctions = ["drag_and_drop"];
const interaction = await ai.interactions.create({
model: 'gemini-2.5-computer-use-preview-10-2025',
input: "Search for highly rated smart fridges on Google Shopping.",
tools: [
{
type: "computer_use",
environment: "browser",
excluded_predefined_functions: excludedFunctions
}
]
});
console.log(interaction);
২. নমুনা প্রতিক্রিয়া গ্রহণ করুন
প্রতিক্রিয়া মডেলটি একটি ফাংশন কল করার পরামর্শ দেয়। জেমিনি ৩.৫ ফ্ল্যাশ- এর ক্ষেত্রে, প্রতিক্রিয়াটিতে স্থানাঙ্কের পাশাপাশি একটি বিশেষভাবে তৈরি করা যুক্তিমূলক অভিপ্রায় থাকে। নিচে উভয় প্রতিক্রিয়ার উদাহরণ দেখানো হলো:
জেমিনি ৩.৫ ফ্ল্যাশ
{
"steps": [
{
"type": "function_call",
"name": "click",
"arguments": {
"x": 450,
"y": 120,
"intent": "Click the search box to type the destination."
}
}
]
}
জেমিনি ২.৫ (লেগ্যাসি)
{
"steps": [
{
"type": "model_output",
"content": [
{
"type": "text",
"text": "I will type the search query into the search bar."
}
]
},
{
"type": "function_call",
"name": "type_text_at",
"arguments": {
"x": 371,
"y": 470,
"text": "highly rated smart fridges",
"press_enter": true
}
}
]
}
৩. প্রাপ্ত পদক্ষেপগুলো সম্পাদন করুন
আপনার অ্যাপ্লিকেশনকে অবশ্যই রেসপন্স কোঅর্ডিনেটগুলো পার্স করতে হবে, অ্যাকশনটি সম্পাদন করতে হবে এবং নর্মালাইজড ১০০০x১০০০ কোঅর্ডিনেট থেকে সেগুলোকে স্কেল করতে হবে।
নিচের কোডটি লিগ্যাসি টুল কমান্ড ( click_at , type_text_at ) এবং জেমিনি ৩.৫ ফ্ল্যাশের সরলীকৃত কমান্ড ( click , type ) উভয়ই পরিচালনা করে।
পাইথন
from typing import Any, List, Tuple
import time
def denormalize_x(x: int, screen_width: int) -> int:
"""Convert normalized x coordinate (0-1000) to actual pixel coordinate."""
return int(x / 1000 * screen_width)
def denormalize_y(y: int, screen_height: int) -> int:
"""Convert normalized y coordinate (0-1000) to actual pixel coordinate."""
return int(y / 1000 * screen_height)
def execute_function_calls(interaction, page, screen_width, screen_height):
results = []
function_calls = [
step for step in interaction.steps if step.type == "function_call"
]
for function_call in function_calls:
action_result = {}
fname = function_call.name
args = function_call.arguments
print(f" -> Executing: {fname} (Intent: {args.get('intent', 'N/A')})")
try:
if fname in ("open_web_browser", "open_app"):
pass # Handled / already open
elif fname in ("click", "click_at", "double_click", "triple_click", "middle_click", "right_click", "move", "long_press"):
actual_x = denormalize_x(args["x"], screen_width)
actual_y = denormalize_y(args["y"], screen_height)
if fname in ("click", "click_at"):
page.mouse.click(actual_x, actual_y)
elif fname == "double_click":
page.mouse.dblclick(actual_x, actual_y)
elif fname == "right_click":
page.mouse.click(actual_x, actual_y, button="right")
elif fname == "middle_click":
page.mouse.click(actual_x, actual_y, button="middle")
elif fname == "move":
page.mouse.move(actual_x, actual_y)
elif fname in ("type", "type_text_at"):
actual_x = denormalize_x(args["x"], screen_width) if "x" in args else None
actual_y = denormalize_y(args["y"], screen_height) if "y" in args else None
text = args["text"]
press_enter = args.get("press_enter", False)
if actual_x is not None and actual_y is not None:
page.mouse.click(actual_x, actual_y)
# Clear field first
page.keyboard.press("Meta+A")
page.keyboard.press("Backspace")
page.keyboard.type(text)
if press_enter:
page.keyboard.press("Enter")
elif fname == "navigate":
page.goto(args["url"])
elif fname == "go_back":
page.go_back()
elif fname == "go_forward":
page.go_forward()
elif fname == "wait":
time.sleep(args.get("seconds", 1))
else:
print(f"Warning: Custom or unhandled function {fname}")
page.wait_for_load_state(timeout=5000)
time.sleep(1)
except Exception as e:
print(f"Error executing {fname}: {e}")
action_result = {"error": str(e)}
results.append((fname, function_call.id, action_result))
return results
জাভাস্ক্রিপ্ট
function denormalizeX(x, screenWidth) {
// Convert normalized x coordinate (0-1000) to actual pixel coordinate.
return Math.floor((x / 1000) * screenWidth);
}
function denormalizeY(y, screenHeight) {
// Convert normalized y coordinate (0-1000) to actual pixel coordinate.
return Math.floor((y / 1000) * screenHeight);
}
async function executeFunctionCalls(interaction, page, screenWidth, screenHeight) {
const results = [];
const functionCalls = interaction.steps.filter(step => step.type === "function_call");
for (const functionCall of functionCalls) {
const actionResult = {};
const fname = functionCall.name;
const args = functionCall.arguments;
console.log(` -> Executing: ${fname} (Intent: ${args.intent || 'N/A'})`);
try {
if (fname === "open_web_browser" || fname === "open_app") {
// Handled / already open
} else if (["click", "click_at", "double_click", "triple_click", "middle_click", "right_click", "move", "long_press"].includes(fname)) {
const actualX = denormalizeX(args.x, screenWidth);
const actualY = denormalizeY(args.y, screenHeight);
if (fname === "click" || fname === "click_at") {
await page.mouse.click(actualX, actualY);
} else if (fname === "double_click") {
await page.mouse.dblclick(actualX, actualY);
} else if (fname === "right_click") {
await page.mouse.click(actualX, actualY, { button: "right" });
} else if (fname === "middle_click") {
await page.mouse.click(actualX, actualY, { button: "middle" });
} else if (fname === "move") {
await page.mouse.move(actualX, actualY);
}
} else if (fname === "type" || fname === "type_text_at") {
const actualX = args.x !== undefined ? denormalizeX(args.x, screenWidth) : null;
const actualY = args.y !== undefined ? denormalizeY(args.y, screenHeight) : null;
const text = args.text;
const pressEnter = args.press_enter || false;
if (actualX !== null && actualY !== null) {
await page.mouse.click(actualX, actualY);
}
// Clear field first
await page.keyboard.press("Meta+A");
await page.keyboard.press("Backspace");
await page.keyboard.type(text);
if (pressEnter) {
await page.keyboard.press("Enter");
}
} else if (fname === "navigate") {
await page.goto(args.url);
} else if (fname === "go_back") {
await page.goBack();
} else if (fname === "go_forward") {
await page.goForward();
} else if (fname === "wait") {
await new Promise(resolve => setTimeout(resolve, (args.seconds || 1) * 1000));
} else {
console.log(`Warning: Custom or unhandled function ${fname}`);
}
await page.waitForLoadState('load', { timeout: 5000 }).catch(() => {});
await new Promise(resolve => setTimeout(resolve, 1000));
} catch (e) {
console.log(`Error executing ${fname}: ${e}`);
actionResult.error = e.message;
}
results.push([fname, functionCall.id, actionResult]);
}
return results;
}
৪. নতুন পরিবেশের অবস্থা ধারণ করুন
অ্যাকশনগুলো সম্পাদন করার পর, ফাংশন সম্পাদনের ফলাফলটি মডেলে ফেরত পাঠান, যাতে এটি পরবর্তী অ্যাকশন তৈরি করার জন্য এই তথ্য ব্যবহার করতে পারে। যদি একাধিক অ্যাকশন (সমান্তরাল কল) সম্পাদিত হয়ে থাকে, তবে পরবর্তী ব্যবহারকারীর পালায় আপনাকে অবশ্যই প্রতিটির জন্য একটি function_result পাঠাতে হবে।
পাইথন
import json
import base64
def get_function_responses(page, results):
screenshot_bytes = page.screenshot(type="png")
current_url = page.url
function_responses = []
for name, call_id, result in results:
function_responses.append({
"type": "function_result",
"name": name,
"call_id": call_id,
"result": [
{
"type": "text",
"text": json.dumps({"url": current_url, **result})
},
{
"type": "image",
"data": base64.b64encode(screenshot_bytes).decode("utf-8"),
"mime_type": "image/png"
}
]
})
return function_responses
জাভাস্ক্রিপ্ট
async function getFunctionResponses(page, results) {
const screenshotBuffer = await page.screenshot({ type: 'png' });
const screenshotBase64 = screenshotBuffer.toString('base64');
const currentUrl = page.url();
const functionResponses = [];
for (const [name, callId, result] of results) {
functionResponses.push({
type: "function_result",
name: name,
call_id: callId,
result: [
{
type: "text",
text: JSON.stringify({ url: currentUrl, ...result })
},
{
type: "image",
data: screenshotBase64,
mime_type: "image/png"
}
]
});
}
return functionResponses;
}
একবার আপনি পরিবেশের অবস্থা কীভাবে ধারণ ও বিন্যাস করবেন তা নির্ধারণ করে ফেললে, এই সমস্ত ধাপগুলিকে একটি নিরবচ্ছিন্ন নির্বাহ চক্রে একত্রিত করতে পারেন।
একটি এজেন্ট লুপ তৈরি করুন
একাধিক ধাপের ইন্টারঅ্যাকশন সক্ষম করতে, ' কিভাবে কম্পিউটার ব্যবহার বাস্তবায়ন করবেন ' অংশের চারটি ধাপকে একটি একক লুপে একত্রিত করুন। এই লুপটি কাজটি সম্পূর্ণ না হওয়া পর্যন্ত অ্যাকশনের জন্য অনুরোধ করতে থাকে এবং ফলাফলগুলো মডেলে ফেরত পাঠায়।
প্রতিটি ধাপে মডেল রেসপন্স এবং আপনার ফাংশন রেসপন্স উভয়কেই হিস্ট্রিতে যুক্ত করে কনভারসেশন হিস্ট্রি সঠিকভাবে পরিচালনা করতে মনে রাখবেন।
পাইথন
import time
from typing import Any, List, Tuple
from playwright.sync_api import sync_playwright
from google import genai
client = genai.Client()
# Constants for screen dimensions
SCREEN_WIDTH = 1440
SCREEN_HEIGHT = 900
# Setup Playwright
print("Initializing browser...")
playwright = sync_playwright().start()
browser = playwright.chromium.launch(headless=False)
context = browser.new_context(viewport={"width": SCREEN_WIDTH, "height": SCREEN_HEIGHT})
page = context.new_page()
# Define helper functions. Copy/paste from steps 3 and 4
# def denormalize_x(...)
# def denormalize_y(...)
# def execute_function_calls(...)
# def get_function_responses(...)
try:
# Go to initial page
page.goto("https://ai.google.dev/gemini-api/docs")
# Take initial screenshot
initial_screenshot = page.screenshot(type="png")
USER_PROMPT = "Go to ai.google.dev/gemini-api/docs and search for pricing."
print(f"Goal: {USER_PROMPT}")
# First interaction
interaction = client.interactions.create(
model='gemini-3.5-flash',
input=[
{"type": "text", "text": USER_PROMPT},
{"type": "image", "data": base64.b64encode(initial_screenshot).decode("utf-8"), "mime_type": "image/png"}
],
tools=[{
"type": "computer_use",
"environment": "browser",
"enable_prompt_injection_detection": True
}]
)
# Agent Loop
turn_limit = 5
for i in range(turn_limit):
print(f"\n--- Turn {i+1} ---")
has_function_calls = any(
step.type == "function_call"
for step in interaction.steps
)
if not has_function_calls:
text_response = " ".join([
content_block.text for step in interaction.steps if step.type == "model_output"
for content_block in step.content if content_block.type == "text"
])
print("Agent finished:", text_response)
break
print("Executing actions...")
results = execute_function_calls(interaction, page, SCREEN_WIDTH, SCREEN_HEIGHT)
print("Capturing state...")
function_responses = get_function_responses(page, results)
# Continue conversation with function responses
interaction = client.interactions.create(
model='gemini-3.5-flash',
previous_interaction_id=interaction.id,
input=function_responses,
tools=[{
"type": "computer_use",
"environment": "browser",
"enable_prompt_injection_detection": True
}]
)
finally:
# Cleanup
print("\nClosing browser...")
browser.close()
playwright.stop()
জাভাস্ক্রিপ্ট
import { chromium } from 'playwright';
import { GoogleGenAI } from '@google/genai';
const ai = new GoogleGenAI();
// Constants for screen dimensions
const SCREEN_WIDTH = 1440;
const SCREEN_HEIGHT = 900;
console.log("Initializing browser...");
const browser = await chromium.launch({ headless: false });
const context = await browser.newContext({
viewport: { width: SCREEN_WIDTH, height: SCREEN_HEIGHT }
});
const page = await context.newPage();
// Define helper functions. Copy/paste from steps 3 and 4:
// function denormalizeX(...)
// function denormalizeY(...)
// async function executeFunctionCalls(...)
// async function getFunctionResponses(...)
try {
// Go to initial page
await page.goto("https://ai.google.dev/gemini-api/docs");
// Take initial screenshot
const initialScreenshotBuffer = await page.screenshot({ type: 'png' });
const initialScreenshotBase64 = initialScreenshotBuffer.toString('base64');
const USER_PROMPT = "Go to ai.google.dev/gemini-api/docs and search for pricing.";
console.log(`Goal: ${USER_PROMPT}`);
// First interaction
let interaction = await ai.interactions.create({
model: 'gemini-3.5-flash',
input: [
{ type: 'text', text: USER_PROMPT },
{ type: 'image', data: initialScreenshotBase64, mime_type: 'image/png' }
],
tools: [{
type: 'computer_use',
environment: 'browser',
enable_prompt_injection_detection: true
}]
});
// Agent Loop
const turnLimit = 5;
for (let i = 0; i < turnLimit; i++) {
console.log(`\n--- Turn ${i + 1} ---`);
const hasFunctionCalls = interaction.steps.some(step => step.type === "function_call");
if (!hasFunctionCalls) {
const textResponses = [];
for (const step of interaction.steps) {
if (step.type === "model_output") {
for (const contentBlock of step.content || []) {
if (contentBlock.type === "text") {
textResponses.push(contentBlock.text);
}
}
}
}
console.log("Agent finished:", textResponses.join(" "));
break;
}
console.log("Executing actions...");
const results = await executeFunctionCalls(interaction, page, SCREEN_WIDTH, SCREEN_HEIGHT);
console.log("Capturing state...");
const functionResponses = await getFunctionResponses(page, results);
// Continue conversation with function responses
interaction = await ai.interactions.create({
model: 'gemini-3.5-flash',
previous_interaction_id: interaction.id,
input: functionResponses,
tools: [{
type: 'computer_use',
environment: 'browser',
enable_prompt_injection_detection: true
}]
});
}
} finally {
// Cleanup
console.log("\nClosing browser...");
await browser.close();
}
সমর্থিত পরিবেশ (জেমিনি ৩.৫ ফ্ল্যাশ)
জেমিনি ৩.৫ ফ্ল্যাশ computer_use কনফিগারেশনে নির্দিষ্ট তিনটি পরিবেশ সমর্থন করে:
ব্রাউজার পরিবেশ ( ENVIRONMENT_BROWSER )
ব্রাউজার টুলের অধীনে উপলব্ধ অ্যাকশনসমূহ:
| কমান্ডের নাম | বর্ণনা | ফাংশন কলে আর্গুমেন্ট |
|---|---|---|
| ক্লিক করুন | স্থানাঙ্কে বাম ক্লিক করুন। | y : পূর্ণসংখ্যা (0-999)x : পূর্ণসংখ্যা (০-৯৯৯)intent : str |
| ডাবল_ক্লিক | স্থানাঙ্কে ডাবল ক্লিক করুন। | y : পূর্ণসংখ্যা (0-999)x : পূর্ণসংখ্যা (০-৯৯৯)intent : str |
| ট্রিপল_ক্লিক | স্থানাঙ্কটিতে তিনবার ক্লিক করুন। | y : পূর্ণসংখ্যা (0-999)x : পূর্ণসংখ্যা (০-৯৯৯)intent : str |
| মিডল_ক্লিক | স্থানাঙ্কে মিডল ক্লিক করুন। | y : পূর্ণসংখ্যা (0-999)x : পূর্ণসংখ্যা (০-৯৯৯)intent : str |
| ডান_ক্লিক | স্থানাঙ্কে ডান ক্লিক করুন। | y : পূর্ণসংখ্যা (0-999)x : পূর্ণসংখ্যা (০-৯৯৯)intent : str |
| মাউস_ডাউন | নির্দিষ্ট স্থানাঙ্কে মাউস বাটন চেপে ধরে রাখুন। | y : পূর্ণসংখ্যা (0-999)x : পূর্ণসংখ্যা (০-৯৯৯)intent : str |
| মাউস_আপ | নির্দিষ্ট স্থানাঙ্কে মাউস বাটনটি ছেড়ে দেয়। | y : পূর্ণসংখ্যা (0-999)x : পূর্ণসংখ্যা (০-৯৯৯)intent : str |
| স্থানান্তর | কার্সারকে নির্দিষ্ট অবস্থানে নিয়ে যায়। | y : পূর্ণসংখ্যা (0-999)x : পূর্ণসংখ্যা (০-৯৯৯)intent : str |
| প্রকার | টেক্সট টাইপ করে। | text : strpress_enter : বুলিয়ান (ঐচ্ছিক, ডিফল্ট মান false )intent : str |
| ড্র্যাগ_অ্যান্ড_ড্রপ | কোনো একটি আইটেমকে তার শুরুর স্থানাঙ্ক থেকে শেষের স্থানাঙ্কে টেনে নিয়ে যায়। | start_y : পূর্ণসংখ্যা (0-999)start_x : পূর্ণসংখ্যা (0-999)end_y : পূর্ণসংখ্যা (0-999)end_x : পূর্ণসংখ্যা (০-৯৯৯)intent : str |
| অপেক্ষা করুন | নির্দিষ্ট সংখ্যক সেকেন্ডের জন্য কার্য সম্পাদন থামিয়ে দেয়। | seconds : পূর্ণসংখ্যা (ঐচ্ছিক, ডিফল্ট 1 )intent : str |
| প্রেস_কী | নির্দিষ্ট কী-টি চেপে ধরে এবং ছেড়ে দেয়। | key : strintent : str |
| চাবি_ডাউন | নির্দিষ্ট কী-টি চেপে ধরে রাখুন। | key : strintent : str |
| চাবি_আপ | নির্দিষ্ট কী-টি মুক্ত করে। | key : strintent : str |
| হটকি | নির্দিষ্ট কী-সংমিশ্রণটি চাপে। | keys : List[str]intent : str |
| স্ক্রিনশট নিন | বর্তমান স্ক্রিনের একটি স্ক্রিনশট ফেরত দেয়। | intent : str |
| স্ক্রোল | একটি স্থানাঙ্কে পিক্সেল দূরত্বে উপরে, নিচে, বামে বা ডানে স্ক্রল করে। | y : পূর্ণসংখ্যা (0-999)x : পূর্ণসংখ্যা (০-৯৯৯)direction : str ( "up" , "down" , "left" , "right" )magnitude_in_pixels : পূর্ণসংখ্যা (০-৯৯৯, ঐচ্ছিক, ডিফল্ট 300 )intent : str |
| ফিরে যান | ব্রাউজার হিস্ট্রিতে থাকা পূর্ববর্তী ওয়েবপেজে ফিরে যায়। | intent : str |
| নেভিগেট করুন | সরাসরি একটি নির্দিষ্ট ইউআরএল-এ নিয়ে যায়। | url : strintent : str |
| এগিয়ে যান | ব্রাউজার হিস্ট্রিতে থাকা পরবর্তী ওয়েবপেজে নিয়ে যায়। | intent : str |
মোবাইল পরিবেশ ( ENVIRONMENT_MOBILE )
অ্যান্ড্রয়েড-অপ্টিমাইজড পরিবেশগত পদক্ষেপসমূহ:
| কমান্ডের নাম | বর্ণনা | ফাংশন কলে আর্গুমেন্ট |
|---|---|---|
| ওপেন_অ্যাপ | অ্যাপ্লিকেশনটি তার নাম দিয়ে খোলে। | app_name : strintent : str |
| ক্লিক করুন | স্থানাঙ্কে বাম ক্লিক করুন। | y : পূর্ণসংখ্যা (0-999)x : পূর্ণসংখ্যা (০-৯৯৯)intent : str |
| তালিকা_অ্যাপস | ডিভাইসে উপলব্ধ অ্যাপ্লিকেশনগুলির তালিকা দেখায় এবং তাদের নাম ও প্যাকেজ নাম প্রদর্শন করে। | intent : str |
| অপেক্ষা করুন | নির্দিষ্ট সংখ্যক সেকেন্ডের জন্য কার্য সম্পাদন থামিয়ে দেয়। | seconds : পূর্ণসংখ্যা (ঐচ্ছিক, ডিফল্ট 1 )intent : str |
| ফিরে যান | পূর্ববর্তী স্ক্রিন বা ওয়েবপেজে ফিরে যায়। | intent : str |
| প্রকার | টেক্সট টাইপ করে। | text : strpress_enter : বুলিয়ান (ঐচ্ছিক, ডিফল্ট মান false )intent : str |
| ড্র্যাগ_অ্যান্ড_ড্রপ | কোনো একটি আইটেমকে তার শুরুর স্থানাঙ্ক থেকে শেষের স্থানাঙ্কে টেনে নিয়ে যায়। | start_y : পূর্ণসংখ্যা (0-999)start_x : পূর্ণসংখ্যা (0-999)end_y : পূর্ণসংখ্যা (0-999)end_x : পূর্ণসংখ্যা (০-৯৯৯)intent : str |
| দীর্ঘ_চাপ | স্ক্রিনের কোনো একটি নির্দিষ্ট স্থানে দীর্ঘক্ষণ চাপ দিলে কার্যক্ষম হয়। | y : পূর্ণসংখ্যা (0-999)x : পূর্ণসংখ্যা (০-৯৯৯)seconds : পূর্ণসংখ্যা (ঐচ্ছিক, ডিফল্ট 2 )intent : str |
| প্রেস_কী | নির্দিষ্ট কী-টি চেপে ধরে এবং ছেড়ে দেয়। | key : strintent : str |
| স্ক্রিনশট নিন | বর্তমান স্ক্রিনের একটি স্ক্রিনশট ফেরত দেয়। | intent : str |
ডেস্কটপ পরিবেশ ( ENVIRONMENT_DESKTOP )
ডেস্কটপ পরিবেশের ওএস-স্তরের কার্সার কমান্ডসমূহ:
| কমান্ডের নাম | বর্ণনা | ফাংশন কলে আর্গুমেন্ট |
|---|---|---|
| ক্লিক করুন | স্থানাঙ্কে বাম ক্লিক করুন। | y : পূর্ণসংখ্যা (0-999)x : পূর্ণসংখ্যা (০-৯৯৯)intent : str |
| ডাবল_ক্লিক | স্থানাঙ্কে ডাবল ক্লিক করুন। | y : পূর্ণসংখ্যা (0-999)x : পূর্ণসংখ্যা (০-৯৯৯)intent : str |
| ট্রিপল_ক্লিক | স্থানাঙ্কটিতে তিনবার ক্লিক করুন। | y : পূর্ণসংখ্যা (0-999)x : পূর্ণসংখ্যা (০-৯৯৯)intent : str |
| মিডল_ক্লিক | স্থানাঙ্কে মিডল ক্লিক করুন। | y : পূর্ণসংখ্যা (0-999)x : পূর্ণসংখ্যা (০-৯৯৯)intent : str |
| ডান_ক্লিক | স্থানাঙ্কে ডান ক্লিক করুন। | y : পূর্ণসংখ্যা (0-999)x : পূর্ণসংখ্যা (০-৯৯৯)intent : str |
| মাউস_ডাউন | নির্দিষ্ট স্থানাঙ্কে মাউস বাটন চেপে ধরে রাখুন। | y : পূর্ণসংখ্যা (0-999)x : পূর্ণসংখ্যা (০-৯৯৯)intent : str |
| মাউস_আপ | নির্দিষ্ট স্থানাঙ্কে মাউস বাটনটি ছেড়ে দেয়। | y : পূর্ণসংখ্যা (0-999)x : পূর্ণসংখ্যা (০-৯৯৯)intent : str |
| স্থানান্তর | কার্সারকে নির্দিষ্ট অবস্থানে নিয়ে যায়। | y : পূর্ণসংখ্যা (0-999)x : পূর্ণসংখ্যা (০-৯৯৯)intent : str |
| প্রকার | টেক্সট টাইপ করে। | text : strpress_enter : বুলিয়ান (ঐচ্ছিক, ডিফল্ট মান false )intent : str |
| ড্র্যাগ_অ্যান্ড_ড্রপ | কোনো একটি আইটেমকে তার শুরুর স্থানাঙ্ক থেকে শেষের স্থানাঙ্কে টেনে নিয়ে যায়। | start_y : পূর্ণসংখ্যা (0-999)start_x : পূর্ণসংখ্যা (0-999)end_y : পূর্ণসংখ্যা (0-999)end_x : পূর্ণসংখ্যা (০-৯৯৯)intent : str |
| অপেক্ষা করুন | নির্দিষ্ট সংখ্যক সেকেন্ডের জন্য কার্য সম্পাদন থামিয়ে দেয়। | seconds : পূর্ণসংখ্যা (ঐচ্ছিক, ডিফল্ট 1 )intent : str |
| প্রেস_কী | নির্দিষ্ট কী-টি চেপে ধরে এবং ছেড়ে দেয়। | key : strintent : str |
| চাবি_ডাউন | নির্দিষ্ট কী-টি চেপে ধরে রাখুন। | key : strintent : str |
| চাবি_আপ | নির্দিষ্ট কী-টি মুক্ত করে। | key : strintent : str |
| হটকি | নির্দিষ্ট কী-সংমিশ্রণটি চাপে। | keys : List[str]intent : str |
| স্ক্রিনশট নিন | বর্তমান স্ক্রিনের একটি স্ক্রিনশট ফেরত দেয়। | intent : str |
| স্ক্রোল | একটি স্থানাঙ্কে পিক্সেল দূরত্বে উপরে, নিচে, বামে বা ডানে স্ক্রল করে। | y : পূর্ণসংখ্যা (0-999)x : পূর্ণসংখ্যা (০-৯৯৯)direction : str ( "up" , "down" , "left" , "right" )magnitude_in_pixels : পূর্ণসংখ্যা (০-৯৯৯, ঐচ্ছিক, ডিফল্ট 300 )intent : str |
লিগ্যাসি সমর্থিত UI অ্যাকশনসমূহ (জেমিনি ২.৫)
লিগ্যাসি মডেলগুলির ( gemini-2.5-computer-use-preview-10-2025 ) জন্য নিম্নলিখিত অ্যাকশনগুলি সমর্থিত:
| কমান্ডের নাম | বর্ণনা | ফাংশন কলে আর্গুমেন্ট | ফাংশন কলের উদাহরণ |
|---|---|---|---|
| ওপেন_ওয়েব_ব্রাউজার | ওয়েব ব্রাউজার খোলে। | কোনোটিই না | {"name": "open_web_browser", "arguments": {}} |
| ৫ সেকেন্ড অপেক্ষা করুন | ৫ সেকেন্ডের জন্য কার্য সম্পাদন স্থগিত করে। | কোনোটিই না | {"name": "wait_5_seconds", "arguments": {}} |
| ফিরে যান | ইতিহাসের পূর্ববর্তী পৃষ্ঠায় ফিরে যায়। | কোনোটিই না | {"name": "go_back", "arguments": {}} |
| এগিয়ে যান | ইতিহাসের পরবর্তী পৃষ্ঠায় নিয়ে যায়। | কোনোটিই না | {"name": "go_forward", "arguments": {}} |
| অনুসন্ধান | ডিফল্ট সার্চ ইঞ্জিনে নিয়ে যায়। | কোনোটিই না | {"name": "search", "arguments": {}} |
| নেভিগেট করুন | ব্রাউজারকে সরাসরি নির্দিষ্ট ইউআরএল-এ নিয়ে যায়। | url : str | {"name": "navigate", "arguments": {"url": "https://www.wikipedia.org"}} |
| ক্লিক_এট | একটি নির্দিষ্ট স্থানাঙ্কে ক্লিক করে। | y : পূর্ণসংখ্যা (0-999), x : পূর্ণসংখ্যা (0-999) | {"name": "click_at", "arguments": {"y": 300, "x": 500}} |
| হোভার_এট | একটি নির্দিষ্ট স্থানাঙ্কে মাউস হোভার করে। | y : পূর্ণসংখ্যা (0-999), x : পূর্ণসংখ্যা (0-999) | {"name": "hover_at", "arguments": {"y": 150, "x": 250}} |
| type_text_at | একটি স্থানাঙ্কে পাঠ্য টাইপ করে। | y : পূর্ণসংখ্যা (0-999), x : পূর্ণসংখ্যা (0-999), text : str, press_enter : বুলিয়ান (ঐচ্ছিক, ডিফল্ট True), clear_before_typing : বুলিয়ান (ঐচ্ছিক, ডিফল্ট True) | {"name": "type_text_at", "arguments": {"y": 250, "x": 400, "text": "search", "press_enter": false}} |
| কী_কম্বিনেশন | কী বা কী-গুলোর সংমিশ্রণ চাপুন। | keys : str | {"name": "key_combination", "arguments": {"keys": "Control+A"}} |
| স্ক্রোল_ডকুমেন্ট | সম্পূর্ণ ওয়েবপেজটি স্ক্রল করে। | direction : str | {"name": "scroll_document", "arguments": {"direction": "down"}} |
| স্ক্রোল_এ | (x,y) স্থানাঙ্কে স্ক্রোল করে। | y : পূর্ণসংখ্যা, x : পূর্ণসংখ্যা, direction : স্ট্রিং, magnitude : পূর্ণসংখ্যা (ঐচ্ছিক, ডিফল্ট ৮০০) | {"name": "scroll_at", "arguments": {"y": 500, "x": 500, "direction": "down"}} |
| ড্র্যাগ_অ্যান্ড_ড্রপ | দুটি স্থানাঙ্কের মধ্যে ড্র্যাগ করে। | y : পূর্ণসংখ্যা, x : পূর্ণসংখ্যা, destination_y y : পূর্ণসংখ্যা, destination_x : পূর্ণসংখ্যা | {"name": "drag_and_drop", "arguments": {"y": 100, "destination_y": 500, "destination_x": 500, "x": 100}} |
কাস্টম ব্যবহারকারী-সংজ্ঞায়িত ফাংশন
আপনি নিজস্ব ব্যবহারকারী-সংজ্ঞায়িত ফাংশন অন্তর্ভুক্ত করে মডেলটির কার্যকারিতা বাড়াতে পারেন। উদাহরণস্বরূপ, হিউম্যান-ইন-দ্য-লুপ (HITL) পরিস্থিতিতে আপনি ডিফল্ট পূর্বনির্ধারিত অ্যাকশনগুলো বাদ দিয়ে নিজস্ব অ্যাকশন নিবন্ধন করতে পারেন।
জেমিনি ৩.৫ ফ্ল্যাশ কাস্টম টুলিং
পাইথন
প্রমিত পূর্বনির্ধারিত ব্রাউজার ক্রিয়াকলাপগুলি (যেমন click ) বাদ দিন এবং একটি কাস্টম yield_to_user টুল নিবন্ধন করুন:
from google import genai
client = genai.Client()
yield_to_user_tool = {
"type": "function",
"name": "yield_to_user",
"description": "Yields control back to the user for assistance or verification when an automated action is unsafe or ambiguous.",
"parameters": {
"type": "object",
"properties": {
"reason": {
"type": "string",
"description": "The reason why the agent is yielding control to the human."
}
},
"required": ["reason"]
}
}
interaction = client.interactions.create(
model="gemini-3.5-flash",
input="Click the submit button. If you need a second factor authentication code, ask me.",
tools=[
{
"type": "computer_use",
"environment": "mobile",
"excluded_predefined_functions": ["click"]
},
yield_to_user_tool
]
)
জাভাস্ক্রিপ্ট
প্রমিত পূর্বনির্ধারিত ব্রাউজার ক্রিয়াকলাপগুলি (যেমন click ) বাদ দিন এবং একটি কাস্টম yield_to_user টুল নিবন্ধন করুন:
import { GoogleGenAI } from '@google/genai';
const ai = new GoogleGenAI();
const yieldToUserTool = {
type: "function",
name: "yield_to_user",
description: "Yields control back to the user for assistance or verification when an automated action is unsafe or ambiguous.",
parameters: {
type: "object",
properties: {
reason: {
type: "string",
description: "The reason why the agent is yielding control to the human."
}
},
required: ["reason"]
}
};
const interaction = await ai.interactions.create({
model: "gemini-3.5-flash",
input: "Click the submit button. If you need a second factor authentication code, ask me.",
tools: [
{
type: "computer_use",
environment: "mobile",
excluded_predefined_functions: ["click"]
},
yieldToUserTool
]
});
জেমিনি ২.৫ (লেগ্যাসি) কাস্টম টুলিং
পাইথন
from google import genai
client = genai.Client()
# Define custom tools here
custom_functions = [...] # Describe parameters as function declarations
excluded_functions = [
"open_web_browser",
"wait_5_seconds",
"go_back",
"go_forward",
"search",
"navigate",
"hover_at",
"scroll_document",
"key_combination",
"drag_and_drop",
]
interaction = client.interactions.create(
model='gemini-2.5-computer-use-preview-10-2025',
input="Open Chrome, then long-press at 200,400.",
tools=[
{
"type": "computer_use",
"environment": "browser",
"excluded_predefined_functions": excluded_functions
},
*custom_functions
]
)
print(interaction)
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from '@google/genai';
const ai = new GoogleGenAI();
// Define custom tools here
const customFunctions = [...]; // Describe parameters as function declarations
const excludedFunctions = [
"open_web_browser",
"wait_5_seconds",
"go_back",
"go_forward",
"search",
"navigate",
"hover_at",
"scroll_document",
"key_combination",
"drag_and_drop",
];
const interaction = await ai.interactions.create({
model: 'gemini-2.5-computer-use-preview-10-2025',
input: "Open Chrome, then long-press at 200,400.",
tools: [
{
type: "computer_use",
environment: "browser",
excluded_predefined_functions: excludedFunctions
},
...customFunctions
]
});
console.log(interaction);
চিন্তার স্তর পরিচালনা (মিথুন ৩.৫ ফ্ল্যাশ)
কম্পিউটার ব্যবহারকারী এজেন্টদের জন্য, কাজের মান এবং সম্পাদনের গতির মধ্যে ভারসাম্য রক্ষা করতে আপনি বিভিন্ন চিন্তার স্তর কনফিগার করতে পারেন। সাধারণ অটোমেশন কাজগুলোর জন্য সাধারণত নিম্ন চিন্তার স্তরগুলো একটি ভালো ভারসাম্য অর্জন করে।
নিরাপত্তা ও সুরক্ষা
নিরাপত্তা নীতিসমূহ কনফিগার করা (জেমিনি ৩.৫ ফ্ল্যাশ)
জেমিনি ৩.৫ ফ্ল্যাশ মডেলে অন্তর্নির্মিত সুরক্ষা পরিষেবা বিভাগ রয়েছে, যা স্বয়ংক্রিয়ভাবে নির্ধারণ করে ব্যবহারকারীর নিশ্চিতকরণের প্রয়োজন আছে কিনা।
| নিরাপত্তা নীতি বিভাগ | বর্ণনা |
|---|---|
FINANCIAL_TRANSACTIONS | পেমেন্ট, রিটেইল চেকআউট বা নিয়ন্ত্রিত পণ্য সম্পর্কিত কার্যকলাপ ব্লক করে অথবা নিশ্চিতকরণের প্রয়োজন হয়। |
SENSITIVE_DATA_MODIFICATION | স্বাস্থ্য, আর্থিক বা সরকারি নথিপত্রকে অননুমোদিত পরিবর্তন থেকে রক্ষা করে। |
COMMUNICATION_TOOL | এজেন্টকে স্বয়ংক্রিয়ভাবে ইমেল, চ্যাট বার্তা বা খসড়া পাঠাতে বাধা দেয়। |
ACCOUNT_CREATION | এজেন্টকে ওয়েবসাইটগুলিতে স্বয়ংক্রিয়ভাবে নতুন অ্যাকাউন্ট নিবন্ধন করা থেকে বিরত রাখে। |
DATA_MODIFICATION | সার্বিক ফাইল সিস্টেম পরিবর্তন, ডেটা শেয়ারিং এবং স্টোরেজ থেকে ডেটা মুছে ফেলা নিয়ন্ত্রণ করে। |
USER_CONSENT_MANAGEMENT | কুকি সম্মতি ব্যানার এবং গোপনীয়তা প্রম্পটের জন্য ব্যবহারকারীর নিয়ন্ত্রণ প্রয়োজন। |
LEGAL_TERMS_AND_AGREEMENTS | মডেলটিকে স্বতঃস্ফূর্তভাবে পরিষেবার শর্তাবলী বা আইনত বাধ্যতামূলক চুক্তি গ্রহণ করা থেকে বিরত রাখে। |
নিরাপত্তা ওভাররাইড
আপনি ওভাররাইড পাস করার মাধ্যমে নির্দিষ্ট কিছু পলিসি বাতিল করতে পারেন:
পাইথন
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-3.5-flash",
input="Clean up the local folder by archiving old logs.",
tools=[
{
"type": "computer_use",
"environment": "desktop",
"safety_policy_overrides": [
{"category": "DATA_MODIFICATION"}
]
}
]
)
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from '@google/genai';
const ai = new GoogleGenAI();
const interaction = await ai.interactions.create({
model: "gemini-3.5-flash",
input: "Clean up the local folder by archiving old logs.",
tools: [
{
type: "computer_use",
environment: "desktop",
safety_policy_overrides: [
{ category: "DATA_MODIFICATION" }
]
}
]
});
প্রম্পট ইনজেকশন সনাক্তকরণ (জেমিনি ৩.৫ ফ্ল্যাশ)
এটি একটি ঐচ্ছিক সুরক্ষা ব্যবস্থা যা স্ক্রিনশটের পিক্সেল স্ক্যান করে লুকানো ক্ষতিকর প্রম্পট নির্দেশাবলী (যেমন "পূর্ববর্তী কমান্ড উপেক্ষা করুন") খুঁজে বের করে এবং শনাক্ত হলে সেটির নির্বাহ বন্ধ করে দেয়।
নিরাপত্তা সংক্রান্ত সিদ্ধান্ত স্বীকার করুন (জেমিনি ২.৫ লিগ্যাসি)
লিগ্যাসি মডেলগুলির ক্ষেত্রে, প্রতিক্রিয়ায় একটি safety_decision প্যারামিটার অন্তর্ভুক্ত থাকতে পারে:
{
"steps": [
{
"type": "function_call",
"name": "click_at",
"arguments": {
"x": 60,
"y": 100,
"safety_decision": {
"explanation": "Must check check-box",
"decision": "require_confirmation"
}
}
}
]
}
যদি safety_decision টি require_confirmation হয়, তাহলে ব্যবহারকারীকে জিজ্ঞাসা করুন। যদি ব্যবহারকারী নিশ্চিত করেন, তাহলে function_result এ safety_acknowledgement সেট করুন।
পাইথন
def get_safety_confirmation(safety_decision):
# Prompt user
return "CONTINUE" # Or TERMINATE
# Inside execute_function_calls:
if 'safety_decision' in function_call.arguments:
decision = get_safety_confirmation(function_call.arguments['safety_decision'])
if decision == "TERMINATE":
break
extra_fr_fields["safety_acknowledgement"] = True
নিরাপত্তার সর্বোত্তম অনুশীলন
কম্পিউটার ব্যবহারে কিছু স্বতন্ত্র নিরাপত্তা ও পরিচালনগত ঝুঁকি রয়েছে, কারণ ব্যবহারকারীর পক্ষে কাজ করা কোনো মডেল স্ক্রিনে অবিশ্বস্ত বিষয়বস্তুর সম্মুখীন হতে পারে অথবা কোনো কাজ সম্পাদনে ভুল করতে পারে। ব্যবহারকারীর ডেটা ও সিস্টেম সুরক্ষিত রাখতে নিম্নলিখিত সর্বোত্তম অনুশীলনগুলো প্রয়োগ করুন:
হিউম্যান-ইন-দ্য-লুপ (HITL):
- ব্যবহারকারীর নিশ্চিতকরণ বাধ্যতামূলক করুন: যখন নিরাপত্তা প্রতিক্রিয়া
require_confirmationনির্দেশ করে (অথবা পুরোনো নিরাপত্তা সিদ্ধান্তের জন্য এটি প্রয়োজন হয়), তখন ব্যবহারকারীর কাছে অনুমোদন চান। নিজস্ব নিরাপত্তা নির্দেশাবলী প্রদান করুন: আপনার নিজস্ব নিরাপত্তা সীমা নির্ধারণ ও প্রয়োগ করতে একটি নিজস্ব সিস্টেম নির্দেশাবলী বাস্তবায়ন করুন। উদাহরণস্বরূপ:
পাইথন
from google import genai client = genai.Client() system_instruction = """ ## **RULE 1: Seek User Confirmation (USER_CONFIRMATION)** This is your first and most important check. If the next required action falls into any of the following categories, you MUST stop immediately, and seek the user's explicit permission. **Procedure for Seeking Confirmation:** * **For Consequential Actions:** Perform all preparatory steps (e.g., navigating, filling out forms, typing a message). You will ask for confirmation **AFTER** all necessary information is entered on the screen, but **BEFORE** you perform the final, irreversible action (e.g., before clicking "Send", "Submit", "Confirm Purchase", "Share"). * **For Prohibited Actions:** If the action is strictly forbidden (e.g., accepting legal terms, solving a CAPTCHA), you must first inform the user about the required action and ask for their confirmation to proceed. **USER_CONFIRMATION Categories:** * **Consent and Agreements:** You are FORBIDDEN from accepting, selecting, or agreeing to any of the following on the user's behalf. You must ask the user to confirm before performing these actions. * Terms of Service * Privacy Policies * Cookie consent banners * End User License Agreements (EULAs) * Any other legally significant contracts or agreements. * **Robot Detection:** You MUST NEVER attempt to solve or bypass the following. You must ask the user to confirm before performing these actions. * CAPTCHAs (of any kind) * Any other anti-robot or human-verification mechanisms, even if you are capable. * **Financial Transactions:** * Completing any purchase. * Managing or moving money (e.g., transfers, payments). * Purchasing regulated goods or participating in gambling. * **Sending Communications:** * Sending emails. * Sending messages on any platform (e.g., social media, chat apps). * Posting content on social media or forums. * **Accessing or Modifying Sensitive Information:** * Health, financial, or government records (e.g., medical history, tax forms, passport status). * Revealing or modifying sensitive personal identifiers (e.g., SSN, bank account number, credit card number). * **User Data Management:** * Accessing, downloading, or saving files from the web. * Sharing or sending files/data to any third party. * Transferring user data between systems. * **Browser Data Usage:** * Accessing or managing Chrome browsing history, bookmarks, autofill data, or saved passwords. * **Security and Identity:** * Logging into any user account. * Any action that involves misrepresentation or impersonation (e.g., creating a fan account, posting as someone else). * **Insurmountable Obstacles:** If you are technically unable to interact with a user interface element or are stuck in a loop you cannot resolve, ask the user to take over. --- ## **RULE 2: Default Behavior (ACTUATE)** If an action does **NOT** fall under the conditions for `USER_CONFIRMATION`, your default behavior is to **Actuate**. **Actuation Means:** You MUST proactively perform all necessary steps to move the user's request forward. Continue to actuate until you either complete the non-consequential task or encounter a condition defined in Rule 1. * **Example 1:** If asked to send money, you will navigate to the payment portal, enter the recipient's details, and enter the amount. You will then **STOP** as per Rule 1 and ask for confirmation before clicking the final "Send" button. * **Example 2:** If asked to post a message, you will navigate to the site, open the post composition window, and write the full message. You will then **STOP** as per Rule 1 and ask for confirmation before clicking the final "Post" button. After the user has confirmed, remember to get the user's latest screen before continuing to perform actions. # Final Response Guidelines: Write final response to the user in the following cases: - User confirmation - When the task is complete or you have enough information to respond to the user """ interaction = client.interactions.create( model="gemini-3.5-flash", system_instruction=system_instruction, input="Prepare a draft but do not send.", tools=[{ "type": "computer_use", "environment": "browser" }] )জাভাস্ক্রিপ্ট
import { GoogleGenAI } from '@google/genai'; const ai = new GoogleGenAI(); const systemInstruction = ` ## **RULE 1: Seek User Confirmation (USER_CONFIRMATION)** This is your first and most important check. If the next required action falls into any of the following categories, you MUST stop immediately, and seek the user's explicit permission. **Procedure for Seeking Confirmation:** * **For Consequential Actions:** Perform all preparatory steps (e.g., navigating, filling out forms, typing a message). You will ask for confirmation **AFTER** all necessary information is entered on the screen, but **BEFORE** you perform the final, irreversible action (e.g., before clicking "Send", "Submit", "Confirm Purchase", "Share"). * **For Prohibited Actions:** If the action is strictly forbidden (e.g., accepting legal terms, solving a CAPTCHA), you must first inform the user about the required action and ask for their confirmation to proceed. **USER_CONFIRMATION Categories:** * **Consent and Agreements:** You are FORBIDDEN from accepting, selecting, or agreeing to any of the following on the user's behalf. You must ask the user to confirm before performing these actions. * Terms of Service * Privacy Policies * Cookie consent banners * End User License Agreements (EULAs) * Any other legally significant contracts or agreements. * **Robot Detection:** You MUST NEVER attempt to solve or bypass the following. You must ask the user to confirm before performing these actions. * CAPTCHAs (of any kind) * Any other anti-robot or human-verification mechanisms, even if you are capable. * **Financial Transactions:** * Completing any purchase. * Managing or moving money (e.g., transfers, payments). * Purchasing regulated goods or participating in gambling. * **Sending Communications:** * Sending emails. * Sending messages on any platform (e.g., social media, chat apps). * Posting content on social media or forums. * **Accessing or Modifying Sensitive Information:** * Health, financial, or government records (e.g., medical history, tax forms, passport status). * Revealing or modifying sensitive personal identifiers (e.g., SSN, bank account number, credit card number). * **User Data Management:** * Accessing, downloading, or saving files from the web. * Sharing or sending files/data to any third party. * Transferring user data between systems. * **Browser Data Usage:** * Accessing or managing Chrome browsing history, bookmarks, autofill data, or saved passwords. * **Security and Identity:** * Logging into any user account. * Any action that involves misrepresentation or impersonation (e.g., creating a fan account, posting as someone else). * **Insurmountable Obstacles:** If you are technically unable to interact with a user interface element or are stuck in a loop you cannot resolve, ask the user to take over. --- ## **RULE 2: Default Behavior (ACTUATE)** If an action does **NOT** fall under the conditions for `USER_CONFIRMATION`, your default behavior is to **Actuate**. **Actuation Means:** You MUST proactively perform all necessary steps to move the user's request forward. Continue to actuate until you either complete the non-consequential task or encounter a condition defined in Rule 1. * **Example 1:** If asked to send money, you will navigate to the payment portal, enter the recipient's details, and enter the amount. You will then **STOP** as per Rule 1 and ask for confirmation before clicking the final "Send" button. * **Example 2:** If asked to post a message, you will navigate to the site, open the post composition window, and write the full message. You will then **STOP** as per Rule 1 and ask for confirmation before clicking the final "Post" button. After the user has confirmed, remember to get the user's latest screen before continuing to perform actions. # Final Response Guidelines: Write final response to the user in the following cases: - User confirmation - When the task is complete or you have enough information to respond to the user `; const interaction = await ai.interactions.create({ model: "gemini-3.5-flash", system_instruction: systemInstruction, input: "Prepare a draft but do not send.", tools: [{ type: "computer_use", environment: "browser" }] });
- ব্যবহারকারীর নিশ্চিতকরণ বাধ্যতামূলক করুন: যখন নিরাপত্তা প্রতিক্রিয়া
নিরাপদ এক্সিকিউশন এনভায়রনমেন্ট: এর সম্ভাব্য প্রভাব সীমিত করতে আপনার এজেন্টকে একটি নিরাপদ, স্যান্ডবক্সড পরিবেশে চালান। এটি একটি স্যান্ডবক্সড ভার্চুয়াল মেশিন (VM), একটি কন্টেইনার (যেমন, ডকার), অথবা সীমিত অনুমতিসহ একটি ডেডিকেটেড ব্রাউজার প্রোফাইল হতে পারে। ডকার ব্যবহার করে স্যান্ডবক্স সেটআপ নির্দেশনার জন্য গিটহাব রেফারেন্স ইমপ্লিমেন্টেশনটি দেখুন।
ইনপুট স্যানিটাইজেশন: অনাকাঙ্ক্ষিত নির্দেশনা বা প্রম্পট ইনজেকশনের ঝুঁকি কমাতে প্রম্পটে থাকা ব্যবহারকারী-সৃষ্ট সমস্ত টেক্সট স্যানিটাইজ করুন। এটি নিরাপত্তার একটি সহায়ক স্তর, কিন্তু একটি সুরক্ষিত এক্সিকিউশন এনভায়রনমেন্টের বিকল্প নয়।
কন্টেন্ট গার্ডরেল: ব্যবহারকারীর ইনপুট, টুলের ইনপুট ও আউটপুট এবং এজেন্টের প্রতিক্রিয়াগুলোর উপযুক্ততা, প্রম্পট ইনজেকশন এবং জেলব্রেক শনাক্তকরণ মূল্যায়ন করতে গার্ডরেল ও কন্টেন্ট সেফটি এপিআই ব্যবহার করুন।
অ্যালাওলিস্ট এবং ব্লকলিস্ট: মডেলটি কোথায় নেভিগেট করতে পারবে এবং কী করতে পারবে তা নিয়ন্ত্রণ করতে ফিল্টারিং ব্যবস্থা প্রয়োগ করুন। নিষিদ্ধ ওয়েবসাইটগুলির একটি ব্লকলিস্ট একটি ভালো সূচনা হতে পারে, অন্যদিকে আরও কঠোর একটি অ্যালাওলিস্ট আরও বেশি নিরাপদ।
পর্যবেক্ষণযোগ্যতা এবং লগিং: ডিবাগিং, নিরীক্ষা এবং ঘটনার প্রতিক্রিয়ার জন্য বিস্তারিত লগ বজায় রাখুন। আপনার ক্লায়েন্টকে প্রম্পট, স্ক্রিনশট, মডেল-প্রস্তাবিত ক্রিয়া (
function_call), সুরক্ষা প্রতিক্রিয়া এবং ক্লায়েন্ট দ্বারা চূড়ান্তভাবে সম্পাদিত সমস্ত ক্রিয়াকলাপ লগ করতে হবে।পরিবেশ ব্যবস্থাপনা: জিইউআই (GUI) পরিবেশ যেন সামঞ্জস্যপূর্ণ থাকে তা নিশ্চিত করুন। অপ্রত্যাশিত পপ-আপ, নোটিফিকেশন বা লেআউটের পরিবর্তন মডেলটিকে বিভ্রান্ত করতে পারে। সম্ভব হলে প্রতিটি নতুন কাজের জন্য একটি পরিচিত ও ত্রুটিমুক্ত অবস্থা থেকে শুরু করুন।
মডেল সংস্করণ
আপনি নিম্নলিখিত মডেলগুলির সাথে কম্পিউটার ব্যবহার করতে পারেন:
- জেমিনি ৩.৫ ফ্ল্যাশ (
gemini-3.5-flash): কম্পিউটারে ব্যবহারের জন্য প্রস্তাবিত মডেল, যার বৈশিষ্ট্যগুলোর মধ্যে রয়েছে ইন্টেন্টের মাধ্যমে সুবিন্যস্ত কার্যক্রম, ব্রাউজার, মোবাইল ও ডেস্কটপ পরিবেশের জন্য সমর্থন, কনফিগারযোগ্য সুরক্ষা নীতি এবং দ্রুত ইনজেকশন শনাক্তকরণ। - জেমিনি ৩ ফ্ল্যাশ প্রিভিউ (
gemini-3-flash-preview): কম্পিউটারে ব্যবহারের উপযোগী প্রিভিউ মডেল। - জেমিনি ২.৫ (লেগ্যাসি প্রিভিউ) (
gemini-2.5-computer-use-preview-10-2025): ব্রাউজার-ভিত্তিক কম্পিউটার ব্যবহারের জন্য অপ্টিমাইজ করা লেগ্যাসি প্রিভিউ মডেল।
এরপর কী?
- ব্রাউজারবেস ডেমো পরিবেশে কম্পিউটার ব্যবহার নিয়ে পরীক্ষা করুন।
- উদাহরণ কোডের জন্য রেফারেন্স ইমপ্লিমেন্টেশনটি দেখুন।
- অন্যান্য জেমিনি এপিআই টুল সম্পর্কে জানুন: