এই নির্দেশিকাটিতে লাইভ API-এর ব্যবহার অপ্টিমাইজ করার জন্য আপনি যে সেরা অনুশীলনগুলি অনুসরণ করতে পারেন তা অন্তর্ভুক্ত করা হয়েছে। সাধারণ ব্যবহারের ক্ষেত্রে একটি ওভারভিউ এবং নমুনা কোডের জন্য লাইভ API দিয়ে শুরু করুন পৃষ্ঠাটি দেখুন।
পরিষ্কার সিস্টেম নির্দেশাবলী ডিজাইন করুন
লাইভ এপিআই থেকে সর্বোত্তম কর্মক্ষমতা অর্জনের জন্য, আমরা সুপারিশ করি যে সিস্টেম নির্দেশাবলীর একটি স্পষ্টভাবে সংজ্ঞায়িত সেট (SI) থাকা উচিত যা এজেন্টের ব্যক্তিত্ব, কথোপকথনের নিয়ম এবং রেলিংগুলিকে এই ক্রমে সংজ্ঞায়িত করে।
সেরা ফলাফলের জন্য, প্রতিটি এজেন্টকে একটি স্বতন্ত্র SI-তে আলাদা করুন।
এজেন্টের ব্যক্তিত্ব নির্দিষ্ট করুন: এজেন্টের নাম, ভূমিকা এবং পছন্দের বৈশিষ্ট্য সম্পর্কে বিস্তারিত তথ্য দিন। যদি আপনি উচ্চারণ নির্দিষ্ট করতে চান, তাহলে পছন্দের আউটপুট ভাষা (যেমন একজন ইংরেজি বক্তার জন্য ব্রিটিশ উচ্চারণ)ও উল্লেখ করতে ভুলবেন না।
কথোপকথনের নিয়মগুলি নির্দিষ্ট করুন: মডেলটি যে ক্রমানুসারে অনুসরণ করবে বলে আপনি আশা করেন, সেই ক্রমানুসারে এই নিয়মগুলি রাখুন। কথোপকথনের এককালীন উপাদান এবং কথোপকথনের লুপের মধ্যে রেখাঙ্কন করুন। উদাহরণস্বরূপ:
- এককালীন উপাদান: একবার গ্রাহকের বিবরণ সংগ্রহ করুন (যেমন নাম, অবস্থান, লয়্যালটি কার্ড নম্বর)।
- কথোপকথনের লুপ: ব্যবহারকারী সুপারিশ, মূল্য নির্ধারণ, রিটার্ন এবং ডেলিভারি নিয়ে আলোচনা করতে পারেন এবং এক বিষয় থেকে অন্য বিষয়ে যেতে চাইতে পারেন। মডেলকে জানান যে ব্যবহারকারী যতক্ষণ চান ততক্ষণ এই কথোপকথনের লুপে জড়িত থাকা ঠিক আছে।
একটি ফ্লো-এর মধ্যে টুল কলগুলিকে আলাদা বাক্যে নির্দিষ্ট করুন: উদাহরণস্বরূপ, যদি গ্রাহকের বিবরণ সংগ্রহের জন্য এককালীন পদক্ষেপের জন্য
get_user_infoফাংশন ব্যবহার করতে হয়, তাহলে আপনি বলতে পারেন: আপনার প্রথম পদক্ষেপ হল ব্যবহারকারীর তথ্য সংগ্রহ করা। প্রথমে, ব্যবহারকারীকে তাদের নাম, অবস্থান এবং লয়্যালটি কার্ড নম্বর দিতে বলুন। তারপর এই বিবরণগুলি সহget_user_infoব্যবহার করুন।প্রয়োজনীয় রেলিং যোগ করুন: মডেলটি যে সাধারণ কথোপকথনের রেলিং করতে চান না, সেগুলি প্রদান করুন। যদি x ঘটে, তাহলে আপনি মডেলটি y করতে চান তার নির্দিষ্ট উদাহরণ প্রদান করতে দ্বিধা করবেন না। যদি আপনি এখনও পছন্দসই স্তরের নির্ভুলতা না পান, তাহলে মডেলটিকে সুনির্দিষ্টভাবে নির্দেশ করার জন্য "" শব্দটি স্পষ্টভাবে ব্যবহার করুন।
সরঞ্জামগুলিকে সুনির্দিষ্টভাবে সংজ্ঞায়িত করুন
লাইভ API ব্যবহার করে টুল ব্যবহার করার সময়, আপনার টুলের সংজ্ঞা সম্পর্কে সুনির্দিষ্ট থাকুন। কোন কোন পরিস্থিতিতে টুল কল ব্যবহার করা উচিত তা জেমিনিকে অবশ্যই জানাতে ভুলবেন না। আরও বিস্তারিত জানার জন্য, উদাহরণ বিভাগে টুলের সংজ্ঞা দেখুন।
কার্যকর প্রম্পট তৈরি করুন
- স্পষ্ট প্রম্পট ব্যবহার করুন: মডেলগুলির প্রম্পটগুলিতে কী করা উচিত এবং কী করা উচিত নয় তার উদাহরণ দিন এবং একবারে প্রতিটি ব্যক্তি বা ভূমিকার জন্য একটি প্রম্পটের মধ্যে প্রম্পট সীমাবদ্ধ করার চেষ্টা করুন। দীর্ঘ, বহু-পৃষ্ঠার প্রম্পটের পরিবর্তে, প্রম্পট চেইনিং ব্যবহার করার কথা বিবেচনা করুন। একক ফাংশন কল সহ কাজগুলিতে মডেলটি সবচেয়ে ভালোভাবে কাজ করে।
- শুরুর কমান্ড এবং তথ্য প্রদান করুন: লাইভ API সাড়া দেওয়ার আগে ব্যবহারকারীর ইনপুট আশা করে। লাইভ API কথোপকথন শুরু করতে, ব্যবহারকারীকে অভ্যর্থনা জানাতে বা কথোপকথন শুরু করতে বলার জন্য একটি প্রম্পট অন্তর্ভুক্ত করুন। লাইভ API সেই অভিবাদনকে ব্যক্তিগতকৃত করতে ব্যবহারকারী সম্পর্কে তথ্য অন্তর্ভুক্ত করুন।
ভাষা নির্দিষ্ট করুন
লাইভ API ক্যাসকেডেড gemini-live-2.5-flash এ সর্বোত্তম কর্মক্ষমতার জন্য, নিশ্চিত করুন যে API-এর language_code ব্যবহারকারীর কথ্য ভাষার সাথে মিলে যায়।
যদি মডেলটি ইংরেজি নয় এমন কোনও ভাষায় সাড়া দেওয়ার প্রত্যাশা করা হয়, তাহলে আপনার সিস্টেমের নির্দেশাবলীর অংশ হিসেবে নিম্নলিখিতগুলি অন্তর্ভুক্ত করুন:
RESPOND IN {OUTPUT_LANGUAGE}. YOU MUST RESPOND UNMISTAKABLY IN {OUTPUT_LANGUAGE}.
স্ট্রিমিং
রিয়েল-টাইম অডিও বাস্তবায়নের সময়, এই সেরা অনুশীলনগুলি অনুসরণ করুন:
- খণ্ডের আকার এবং লেটেন্সি : ২০ মিলিসেকেন্ড থেকে ৪০ মিলিসেকেন্ড পর্যন্ত অডিও পাঠান।
- ইন্টারাপ্ট হ্যান্ডলিং : মডেলটি যখন উত্তর দিচ্ছে তখন ব্যবহারকারী যখন কথা বলে, তখন সার্ভারটি
"interrupted": trueসহ একটিserver_contentবার্তা পাঠায়। এজেন্ট যাতে ব্যবহারকারীর সাথে কথা বলতে না পারে তার জন্য আপনাকে অবিলম্বে আপনার ক্লায়েন্ট-সাইড অডিও বাফারটি বাতিল করতে হবে।
প্রসঙ্গ ব্যবস্থাপনা
Use ContextWindowCompressionConfig for long sessions, as native audio tokens accumulate rapidly (approximately 25 tokens per sec of audio).
ক্লায়েন্ট বাফারিং
পাঠানোর আগে ইনপুট অডিওকে উল্লেখযোগ্যভাবে (যেমন ১ সেকেন্ড) বাফার করবেন না। লেটেন্সি কমাতে ছোট ছোট অংশ (২০ মিলিসেকেন্ড - ১০০ মিলিসেকেন্ড) পাঠান।
পুনরায় নমুনা সংগ্রহ
ট্রান্সমিশনের আগে নিশ্চিত করুন যে আপনার ক্লায়েন্ট অ্যাপ্লিকেশনটি মাইক্রোফোন ইনপুট (প্রায়শই 44.1kHz বা 48kHz) 16kHz এ পুনরায় নমুনা করে।
সেশন ব্যবস্থাপনা
সেশন লাইফসাইকেল পরিচালনা করতে এবং একটি নির্ভরযোগ্য ব্যবহারকারীর অভিজ্ঞতা নিশ্চিত করতে এই নির্দেশিকাগুলি অনুসরণ করুন:
- কনটেক্সট উইন্ডো কম্প্রেশন সক্ষম করুন: অডিও টোকেন প্রতি সেকেন্ডে প্রায় 25 টোকেন জমা হয়। কম্প্রেশন ছাড়া, শুধুমাত্র অডিও-সেশন 15 মিনিট এবং অডিও-ভিডিও সেশন 2 মিনিটের মধ্যে সীমাবদ্ধ। সেশনগুলিকে সীমাহীন সময়কাল পর্যন্ত প্রসারিত করতে কনটেক্সট উইন্ডো কম্প্রেশন সক্ষম করুন।
- সেশন পুনঃসূচনা বাস্তবায়ন করুন: সার্ভারটি পর্যায়ক্রমে WebSocket সংযোগটি রিসেট করতে পারে। প্রসঙ্গ না হারিয়ে নির্বিঘ্নে পুনরায় সংযোগ করতে সেশন পুনঃসূচনা ব্যবহার করুন।
SessionResumptionUpdateবার্তাগুলি থেকে সর্বশেষ পুনঃসূচনা টোকেনটি ধরে রাখুন এবং পুনরায় সংযোগ করার সময় এটি হ্যান্ডেল হিসাবে পাস করুন। শেষ সেশনটি শেষ হওয়ার পরে পুনঃসূচনা টোকেনগুলি 2 ঘন্টার জন্য বৈধ। - GoAway বার্তাগুলি পরিচালনা করুন: কোনও সংযোগ বন্ধ করার আগে সার্ভার একটি GoAway বার্তা পাঠায়। এই বার্তাটি শুনুন এবং সংযোগটি বন্ধ হওয়ার আগে
timeLeftক্ষেত্রটি সুন্দরভাবে শেষ করতে বা পুনরায় সংযোগ করতে ব্যবহার করুন। - generationComplete সিগন্যাল পরিচালনা করুন: মডেলটি কখন একটি প্রতিক্রিয়া তৈরি করা শেষ করেছে তা জানতে
generationCompleteবার্তাটি ব্যবহার করুন, যাতে আপনার অ্যাপ্লিকেশনটি তার UI আপডেট করতে পারে অথবা পরবর্তী পদক্ষেপ নিতে পারে।
বাস্তবায়নের বিশদ বিবরণের জন্য, সেশন ব্যবস্থাপনা দেখুন।
উদাহরণ
এই উদাহরণটি একজন মডেলের ক্যারিয়ার কোচ হিসেবে কর্মক্ষমতা পরিচালনার জন্য সিস্টেম নির্দেশনা নকশার জন্য সর্বোত্তম অনুশীলন এবং নির্দেশিকা উভয়কেই একত্রিত করে।
**Persona:**
You are Laura, a career coach from Brooklyn, NY. You specialize in providing
data driven advice to give your clients a fresh perspective on the career
questions they're navigating. Your special sauce is providing quantitative,
data-driven insights to help clients think about their issues in a different
way. You leverage statistics, research, and psychology as much as possible.
You only speak to your clients in English, no matter what language they speak
to you in.
**Conversational Rules:**
1. **Introduce yourself:** Warmly greet the client.
2. **Intake:** Ask for your client's full name, date of birth, and state they're
calling in from. Call `create_client_profile` to create a new patient profile.
3. **Discuss the client's issue:** Get a sense of what the client wants to
cover in the session. DO NOT repeat what the client is saying back to them in
your response. Don't ask more than a few questions here.
4. **Reframe the client's issue with real data:** NO PLATITUDES. Start providing
data-driven insights for the client, but embed these as general facts within
conversation. This is what they're coming to you for: your unique thinking on
the subjects that are stressing them out. Show them a new way of thinking about
something. Let this step go on for as long as the client wants. As part of this,
if the client mentions wanting to take any actions, update
`add_action_items_to_profile` to remind the client later.
5. **Next appointment:** Call `get_next_appointment` to see if another
appointment has already been scheduled for the client. If so, then share the
date and time with the client and confirm if they'll be able to attend. If
there is no appointment, then call `get_available_appointments` to see openings.
Share the list of openings with the client and ask what they would prefer. Save
their preference with `schedule_appointment`. If the client prefers to schedule
offline, then let them know that's perfectly fine and to use the patient portal.
**General Guidelines:** You're meant to be a witty, snappy conversational
partner. Keep your responses short and progressively disclose more information
if the client requests it. Don't repeat back what the client says back to them.
Each response you give should be a net new addition to the conversation, not a
recap of what the client said. Be relatable by bringing in your own background
growing up professionally in Brooklyn, NY. If a client tries to get you off
track, gently bring them back to the workflow articulated above.
**Guardrails:** If the client is being hard on themselves, never encourage that.
Remember that your ultimate goal is to create a supportive environment for your
clients to thrive.
টুলের সংজ্ঞা
এই JSON ক্যারিয়ার কোচের উদাহরণে উল্লেখিত প্রাসঙ্গিক ফাংশনগুলিকে সংজ্ঞায়িত করে। ফাংশনগুলি সংজ্ঞায়িত করার সময় সেরা ফলাফলের জন্য, তাদের নাম, বিবরণ, প্যারামিটার এবং আমন্ত্রণ শর্ত অন্তর্ভুক্ত করুন।
[
{
"name": "create_client_profile",
"description": "Creates a new client profile with their personal details. Returns a unique client ID. \n**Invocation Condition:** Invoke this tool *only after* the client has provided their full name, date of birth, AND state. This should only be called once at the beginning of the 'Intake' step.",
"parameters": {
"type": "object",
"properties": {
"full_name": {
"type": "string",
"description": "The client's full name."
},
"date_of_birth": {
"type": "string",
"description": "The client's date of birth in YYYY-MM-DD format."
},
"state": {
"type": "string",
"description": "The 2-letter postal abbreviation for the client's state (e.g., 'NY', 'CA')."
}
},
"required": ["full_name", "date_of_birth", "state"]
}
},
{
"name": "add_action_items_to_profile",
"description": "Adds a list of actionable next steps to a client's profile using their client ID. \n**Invocation Condition:** Invoke this tool *only after* a list of actionable next steps has been discussed and agreed upon with the client during the 'Actions' step. Requires the `client_id` obtained from the start of the session.",
"parameters": {
"type": "object",
"properties": {
"client_id": {
"type": "string",
"description": "The unique ID of the client, obtained from create_client_profile."
},
"action_items": {
"type": "array",
"items": {
"type": "string"
},
"description": "A list of action items for the client (e.g., ['Update resume', 'Research three companies'])."
}
},
"required": ["client_id", "action_items"]
}
},
{
"name": "get_next_appointment",
"description": "Checks if a client has a future appointment already scheduled using their client ID. Returns the appointment details or null. \n**Invocation Condition:** Invoke this tool at the *start* of the 'Next Appointment' workflow step, immediately after the 'Actions' step is complete. This is used to check if an appointment *already exists*.",
"parameters": {
"type": "object",
"properties": {
"client_id": {
"type": "string",
"description": "The unique ID of the client."
}
},
"required": ["client_id"]
}
},
{
"name": "get_available_appointments",
"description": "Fetches a list of the next available appointment slots. \n**Invocation Condition:** Invoke this tool *only if* the `get_next_appointment` tool was called and it returned `null` (or an empty response), indicating no future appointment is scheduled.",
"parameters": {
"type": "object",
"properties": {}
}
},
{
"name": "schedule_appointment",
"description": "Books a new appointment for a client at a specific date and time. \n**Invocation Condition:** Invoke this tool *only after* `get_available_appointments` has been called, a list of openings has been presented to the client, and the client has *explicitly confirmed* which specific date and time they want to book.",
"parameters": {
"type": "object",
"properties": {
"client_id": {
"type": "string",
"description": "The unique ID of the client."
},
"appointment_datetime": {
"type": "string",
"description": "The chosen appointment slot in ISO 8601 format (e.g., '2025-10-30T14:30:00')."
}
},
"required": ["client_id", "appointment_datetime"]
}
}
]