সোশিয়ালাইট নমুনা অ্যাপে জেনারেটিভ এআই প্রতিক্রিয়া যোগ করুন
সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
সোশিয়ালাইট নমুনা অ্যাপটি দেখায় যে কীভাবে সোশ্যাল নেটওয়ার্ক এবং যোগাযোগ অ্যাপে সাধারণত স্থাপন করা হয় এমন বৈশিষ্ট্যগুলি বাস্তবায়ন করতে Android প্ল্যাটফর্ম API ব্যবহার করতে হয়। আপনার নিজের Android অ্যাপগুলিতে চ্যাটবট ক্ষমতাগুলি কীভাবে প্রয়োগ করা যেতে পারে তা প্রদর্শন করতে আমরা Firebase AI লজিক SDK ব্যবহার করে Gemini API সংহত করেছি।
এই নমুনা কোডটি জেমিনি ফ্ল্যাশ ব্যবহার করে যা দ্রুত এবং সাশ্রয়ী। মিথুন মডেল সম্পর্কে আরও জানুন । সোশ্যালাইট ডেমোতে একটি AI-চালিত চ্যাটবট বাস্তবায়ন করতে, আমরা মডেলের আচরণ পরিবর্তন করতে Gemini API-এর সিস্টেম নির্দেশাবলী কার্যকারিতা ব্যবহার করেছি। এই ক্ষেত্রে, আমরা প্রম্পট ব্যবহার করি "অনুগ্রহ করে একটি বন্ধুত্বপূর্ণ বিড়ালের মতো এই চ্যাট কথোপকথনে সাড়া দিন"। সোসিয়ালাইটের এই জেমিনি-ইনফিউজড সংস্করণটি মডেলের মাল্টিমোডাল ক্ষমতাগুলিকেও ব্যবহার করে যাতে চ্যাটবট ছবিগুলিতে প্রতিক্রিয়া জানায়৷
Gemini API প্রয়োগ করুন
চ্যাটবট বাস্তবায়ন প্রাথমিকভাবে ChatRepository ক্লাসে অবস্থিত। GenerativeModel ক্লাস আপনাকে Gemini API এর সাথে ইন্টারঅ্যাক্ট করতে দেয়, যা নিম্নরূপ ইনস্ট্যান্ট করা হয়:
valgenerativeModel=GenerativeModel(// Set the model name to the latest Gemini model.modelName="gemini-2.0-flash-lite-001",// Set a system instruction to set the behavior of the model.systemInstruction=content{text("Please respond to this chat conversation like a friendly cat.")},)
একটি করুটিন সুযোগে, মডেলটির কথোপকথনের ইতিহাসে অ্যাক্সেস রয়েছে তা নিশ্চিত করতে startChat() এ pastMessages পাস করে একটি চ্যাট শুরু করুন। এটি আপনার চ্যাটবটকে প্রসঙ্গ বজায় রাখার এবং পূর্ববর্তী এক্সচেঞ্জে তৈরি হওয়া সুসংগত প্রতিক্রিয়া তৈরি করার ক্ষমতা দেয়।
এই পৃষ্ঠার কন্টেন্ট ও কোডের নমুনাগুলি Content License-এ বর্ণিত লাইসেন্সের অধীনস্থ। Java এবং OpenJDK হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-07-29 UTC-তে শেষবার আপডেট করা হয়েছে।
[[["সহজে বোঝা যায়","easyToUnderstand","thumb-up"],["আমার সমস্যার সমাধান হয়েছে","solvedMyProblem","thumb-up"],["অন্যান্য","otherUp","thumb-up"]],[["এতে আমার প্রয়োজনীয় তথ্য নেই","missingTheInformationINeed","thumb-down"],["খুব জটিল / অনেক ধাপ","tooComplicatedTooManySteps","thumb-down"],["পুরনো","outOfDate","thumb-down"],["অনুবাদ সংক্রান্ত সমস্যা","translationIssue","thumb-down"],["নমুনা / কোড সংক্রান্ত সমস্যা","samplesCodeIssue","thumb-down"],["অন্যান্য","otherDown","thumb-down"]],["2025-07-29 UTC-তে শেষবার আপডেট করা হয়েছে।"],[],[],null,["# Add generative AI responses the SociaLite sample app\n\nThe [SociaLite sample app](https://github.com/android/socialite) demonstrates how to use Android\nplatform APIs to implement features that are commonly deployed in social network\nand communications apps. We have integrated the Gemini API using the Firebase AI\nLogic SDK to demonstrate how chatbot capabilities can be implemented in your\nown Android apps.\n\nThis sample code uses Gemini Flash which fast and cost-effective.\n[Learn more about the Gemini models](https://firebase.google.com/docs/ai-logic/models). To implement an AI-driven chatbot in\nthe Socialite demo, we used the [*system instructions*](https://firebase.google.com/docs/ai-logic/system-instructions)\nfunctionality of the Gemini API to modify the behavior of the model. In this\ncase, we use the prompt \"Please respond to this chat conversation like a\nfriendly cat\". This Gemini-infused version of SociaLite also uses the multimodal\ncapabilities of the model to let the chatbot react to images.\n\nImplement the Gemini API\n------------------------\n\nThe chatbot implementation is primarily located in the `ChatRepository` class.\nThe `GenerativeModel` class lets you interact with the Gemini API, which is\ninstantiated as follows: \n\n val generativeModel = GenerativeModel(\n // Set the model name to the latest Gemini model.\n modelName = \"gemini-2.0-flash-lite-001\",\n // Set a system instruction to set the behavior of the model.\n systemInstruction = content {\n text(\"Please respond to this chat conversation like a friendly cat.\")\n },\n )\n\nIn a coroutine scope, initiate a chat by passing `pastMessages` to `startChat()`\nto ensure that the model has access to conversation history. This gives your\nchatbot the ability to maintain context and generate coherent responses that\nbuild on previous exchanges. \n\n val pastMessages = getMessageHistory(chatId)\n val chat = generativeModel.startChat(\n history = pastMessages,\n )\n\nUse the `sendMessage()` method to pass messages to the model.\n\nTest the AI chatbot\n-------------------\n\nYou can test it yourself by following these steps:\n\n1. Check out the code for the [SociaLite sample app](https://github.com/android/socialite) and open it in Android Studio.\n2. Set up a Firebase Project, connect your app to the *Gemini Developer API* by following [these steps](https://firebase.google.com/docs/ai-logic/get-started?platform=android&api=dev),\n3. Replace google-services.json with your own \\& Run `app` configuration,\n4. Sync and run your app.\n5. In the SociaLite app, tap **Settings** and then tap **AI Chatbot** so that the button label reads \"*AI Chatbot: enabled*\".\n\nYou are now ready to chat!\n\nAdditional resources\n--------------------\n\n[Learn more about the Firebase AI Logic SDK](/ai/gemini)."]]