Перейти к содержимому

Build Your Own AI Assistant with Python & Gemini API | Full Tutorial #CodeMate #ai #BuildYourOwnAi

CodeMate

0:00 / 0:00

Build Your Own AI Assistant with Python & Gemini API | Full Tutorial #CodeMate #ai #BuildYourOwnAi

105 просмотров · 1 мес. назад
CodeMate
250 подписчиков
105 просмотров · 1 мес. назад
welcome to ‪@CodeMate007‬ 🤖 Build Your Own AI Assistant from Scratch Using Python | Ultron AI In this video, we start building Ultron AI, our own AI assistant using Python and the Gemini API. We build the backend step-by-step, connect Python to Gemini, send user messages, receive and extract Gemini's responses, handle API/network errors, and save the conversation history in a JSON file so Ultron can remember previous conversations even after restarting the program. This is Part 1 — Backend of the project. In the upcoming videos, we'll add voice, build the frontend, and eventually turn Ultron into a complete application that runs on an Android device. ⚡ 📱⏩Python IDE for Android https://play.google.com/store/apps/de... 🔑 GET YOUR GEMINI API KEY 👉 Generate your Gemini API Key here: https://aistudio.google.com/app/api-k... ⚠️ Never share your API key publicly or upload it to GitHub. Google recommends authenticating Gemini API requests with an API key and securing/restricting keys appropriately. Google AI for Developers +1 ⏱️ VIDEO CHAPTERS ​00:00 — Introduction & Project Overview 00:24 — Why We Use a Gemini API Key 00:30 — Understanding API Key Authentication 01:06 — Creating the Gemini API Key 02:17 — Setting Up the Python Project 11:57 — Creating the get_gemini_response() Function 12:14 — Why We Use history as a Parameter 12:35 — Understanding HTTP Headers 12:46 — X-goog-api-key and API Authentication 13:24 — Why We Use Content-Type: application/json 13:48 — Creating the data Variable 13:58 — Why We Send history as contents 14:16 — Sending the Request to Gemini 14:24 — Understanding requests.post() 14:35 — URL, JSON Data & Headers Explained 15:05 — Understanding response.json() 15:30 — Checking the Response Status Code 16:00 — Understanding HTTP Status Codes: 200, 400 & 503 16:42 — Extracting Gemini's Actual Response 16:57 — Understanding Python Dictionary & List Indexing 17:02 — Using candidates[0] to Reach the Response 17:33 — Returning the Extracted Gemini Text 17:41 — Storing the Response in the answer Variable 17:51 — Displaying Ultron: answer 18:02 — Adding the Model Response to Conversation History 18:51 — Why Function Call Order Matters 18:57 — User → Gemini → Model History Flow 20:21 — Creating Persistent Conversation History 20:35 — Connecting the Program to ultron_history.json 21:28 — Using the os Module 21:42 — Checking Whether the History File Exists 22:17 — Why We Use the db File Variable 22:30 — Reading JSON With json.load() 23:10 — Why We Use "w" Mode 23:23 — Writing History With json.dump() 23:38 — Reading Outside the Loop vs Writing Inside the Loop 23:54 — Handling JSONDecodeError 23:58 — Why an Empty JSON File Causes an Error 24:15 — Using try-except for JSON Errors 25:07 — Handling Gemini API Errors 25:10 — Understanding the 429 Limit Error 27:12 — Why None Appears in the Output 27:37 — Using return None to Handle Failed Responses 28:06 — Preventing None From Being Printed 29:13 — Adding Network Error Handling 29:21 — Understanding try and except 30:10 — Handling RequestException 31:36 — Testing the Complete Program 31:44 — Asking Ultron to Remember My Name 31:57 — Restarting the Program 32:05 — Testing Conversation Memory 32:08 — How Ultron Remembers Conversations 32:19 — Viewing ultron_history.json 32:26 — Backend Complete! 32:28 — What's Coming Next 🧠 WHAT WE BUILT In this part, Ultron can: ✅ Communicate with Gemini through the API ✅ Send conversation history to Gemini ✅ Receive and extract Gemini's response ✅ Handle API errors such as 429 ✅ Handle network errors ✅ Store conversations in JSON ✅ Load previous conversations when restarting ✅ Remember information from previous sessions 🔗 USEFUL LINKS 🔑 Gemini API Key: Google AI Studio — API Keys 📚 Gemini API Documentation: Gemini API Documentation 🚀 Gemini API Getting Started: Gemini API — Getting Started 🔐 Gemini API Key Documentation: Using Gemini API Keys 🐍 Python Official Website: Python.org 📌 ABOUT THIS SERIES This is the beginning of the Ultron AI project. Part 1: Python + Gemini API + Backend + Memory Part 2: Voice System 🎙️ Part 3: Frontend 📱 Part 4: Android Application 🚀 The final goal is to turn this simple Python backend into a complete AI assistant that can run on an Android device. #Python #PythonProgramming #PythonProjects #LearnPython #PythonTutorial #AI #ArtificialIntelligence #AIProject #AIAssistant #PersonalAI #AIProgramming #Gemini #GeminiAI #GeminiAPI #GoogleGemini #GoogleAI #GoogleAIStudio #GenerativeAI #GenerativeArtificialIntelligence #MachineLearning #DeepLearning #Chatbot #AIChatbot #PythonAI #PythonAIProject #BuildAI #BuildYourOwnAI #BuildAnAIAssistant #AIDevelopment #SoftwareDevelopment #Programming #Coding #LearnCoding #CodingTutorial #ProgrammingTutorial #Developer #Tech #Technology #BackendDevelopment #API #APITutorial #RESTAPI #JSON #PythonJSON #APIIntegration #AIBackend #UltronAI #CodeMate #Android