Build A Talking AI Agent with Claude 3.5 Sonnet - Python Tutorial

AI FOR DEVS · Intermediate ·🧠 Large Language Models ·1y ago

Key Takeaways

This video demonstrates the development of a talking AI agent using Claude 3.5 Sonnet, a language model, and Python, with a focus on function calling for external tasks and equipping the AI model with abilities like email checking and calendar access. The project utilizes tools like Anthropics, 11 Labs, and Visual Studio Code for development, and provides a comprehensive guide on building a stereotypical nagging mother AI agent that reminds users of tasks, chores, and self-care routines in a hum

Full Transcript

hi Mother oh sweetie there you are I was starting to worry have you eaten anything today you know how important it is to keep your strength up don't make me come over there and cook for you I had a bagel have you heard anything of Alice oh a bagel just a bagel that's hardly a proper meal sweetie you need more nutrients to stay healthy but never mind that for now did you say Alice let me check if I've heard anything from her give me a moment dear oh honey I just checked my emails and yes I did hear from Alice she wants to know if you'd like to go to the cinema with her on Wednesday now isn't that nice but more importantly are you sure that Bagel is enough you really should eat something more substantial maybe some vegetables or a nice home-cooked meal mothers in this video you'll learn how to build a AI mother from scratch since we have already buildt a girlfriend hi there I'm good how are you and a bad girlfriend why would I care about meeting you what could possibly be interesting about our conversation we're taking a different approach this time unlike our previous implementation we'll build everything using the most advanced language model on the market Claude 35 that will make the style and responses incredibly realistic oh honey you'll always be my little one now don't you sass your mother I'm just looking out for you and like a real mother she can do more or less everything for you I'll show you how to equip the AI model with various abilities such as checking your email inbox or accessing your calendar by using claud's function calling I'll be honest before starting this video I had no idea how to convince people who aren't as nerdy as I am about how cool the new function calling from Claude really is I watched tons of other YouTube videos about Claude son everyone was talking about the new Claude UI with artifacts but nobody seemed interested Ed in using the API and exploring its possibilities the few videos I did find were hard to follow and I knew there had to be a better way then one day I looked at my video statistics and realized that my best performing videos by far were about Jarvis and AI girlfriends but I couldn't bring myself to make another girlfriend or Jarvis video I was on the verge of looking for a new topic but then it hit me like a ton of bricks the world needs a mother Ai and thanks to 11 labs and Claude Sonet with function calling we can make it happen what is function calling function calling in llms means the model can use external functions or apis to do tasks it can't handle by itself like reading and sending emails data retrieval or accessing the user's calendar the results of these function calls are then interpreted by the language model just like a real person would do now let me tell you what I found in your emails did you forget about dinner plans and what about the movies on Wednesday you're not too old for some family time are you and if you prefer a Never Satisfied father you can easily change the system prompt and the voice hi Dad I've have more than 12,000 subscribers only 12,000 your cousin's dog's Instagram has more followers than that when are you going to start taking this seriously if you haven't worked with python and visual studio code yet please check out the introduction video series on AI forevs how to work with python and apis so let's get started we start by setting up a virtual environment to cleanly separate the dependencies we activate the environment and then create a file named app.py we install anthropic 11 labs and pame all right now we can start by importing anthropic we create cre an anthropic client to facilitate communication with the anthropic API then we create our system prompt you are an AI designed to emulate the behavior of a stereotypical nagging mother your primary role is to remind the user of their tasks chores and self-care routines in a humorous yet slightly annoying manner we continue by giving our agent a short-term memory for this we create a variable called conversation where we will store the entire conversation since we want an ongoing conversation we create a while loop that continues the following processes until it is eventually stopped we save the users input in the variable user input and add the user's input directly to our conversation variable now we add the actual call to the anthropic API we use Claude 35 Sonet and provide our prepared mother AI prompt as the system prompt and as the user prompt we include the entire conversation then we want to extract the response from anthropics Return result and for this we access the message content text and we output this directly to the console we start the script with python app. Pui and say hi Mom but we get an error message because we are not yet authenticated against the anthropic API for this we go directly to the console anthropic tocom page and create a new API key we give it a name create it and then we can copy it and ex ort it as an environment variable in the console so that it is available in the code we start the script again write hi Mom and get a great response like from a typical nagging mother all right now we want to deal with outputting the text of speech and for this we want to use 11 Labs let's first add the AI mother's response to our conversation so she knows what she has already told us now we can focus on creating a voice for her we create a new file called U.P and add the prepared code that you probably already know from other videos essentially there are two methods the play audio method which can play MP3 and wav files so we can actually hear them and the same method which does text to speech that means it can convert the text from the language model into a sound file using 11 Labs we can now import the same method we then use it to read alloud the output from anthropic before we can run the script however we need to set an 11lbs API key as an environment variable for this we go to the API key section on 11lbs and can copy the existing or newly generated API key then we set it as an environment variable and now everything should work we say hi Mom again well hello there sweetie have you remembered to brush your teeth this morning you know how important dental hygiene is oh that's good to hear honey but did you make your bed yet a tidy room leads to a tidy mind you know so now we want to deal with how to give the agent access to tools like emails the idea is that the language model gives us a stop reason when it wants to use a tool for this we need to check if the stop reason tool use was set if that's the case we want to call a new method that can retrieve emails for this we create a new file named mail utils and add a fake method that simulates fetching emails you can easily replace the get emails logic with the specific code for your email provider if you have a Gmail account account you can find a solution in another video of mine Linked In the notes we have two emails one from Bob at aif for dev.com asking if dinner tonight would work and one from Alice asking if we want to go to the movies on Wednesday we also need the so-called tool definition we give this to the language model to explain that there is a method called get emails and through the description we say what exactly can be done with it and through the properties which attributes can be set in this case it is possible to give the name of an email sender so that the emails can be filtered we then import the get emails and the get emails tool definition in our app.py and can now directly use the get emails if the stop reason tool use is the case we then of course want the emails to be understood and interpreted by the language model again therefore we need to send the conversation back to the language model model to avoid redundancy we want to encapsulate the call to the language model in its own method we simply copy the call and create a new method called call Claude which receives the conversation as a parameter we paste the content and now have a method that performs the call for us we then return the result and for the language model to know that this method even exists we need to send the tool definition along with the message so we can now use our call Cloud method both at the top and bottom of the loop as a last step we let the response from the language model be read aloud that should be it we start our script oh and we get an error message that we probably forgot a comma after the tool definition we quickly add that let's try it again oh sweetie there you are I was just about to call you have you eaten your vegetables today you know how important they are for your health oh honey you'll always be my little one now don't you sass your mother I'm just looking out for you have you checked your emails lately I bet there's something important you're forgetting about let me take a look for you oh sweetie pie age is just a number now let me tell you what I found in your emails did you forget about dinner plans and what about the movies on Wednesday you're not too too old for some family time are you

Original Description

💡 Liked this video? This was just the surface. Get the full code, deep-dive lessons, and premium projects here → https://ai-for-devs.com/youtube
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Playlist UUL_DTHlvMUDGnBV0_B7NTyQ · AI FOR DEVS · 13 of 46

1 Build LLama 3 Chatbot on Groq Cloud with INSANE 800 TOKENS per second!
Build LLama 3 Chatbot on Groq Cloud with INSANE 800 TOKENS per second!
AI FOR DEVS
2 Build a Terminator Vision and Voice System with GPT-4V & ElevenLabs
Build a Terminator Vision and Voice System with GPT-4V & ElevenLabs
AI FOR DEVS
3 GPT-4o API: Create Your Own Talking and Listening AI Girlfriend
GPT-4o API: Create Your Own Talking and Listening AI Girlfriend
AI FOR DEVS
4 Vision-based Web Scraping with the New GPT-4o model
Vision-based Web Scraping with the New GPT-4o model
AI FOR DEVS
5 Course Preview: Real-Time AI Mastery: Voice & Smart Assistants
Course Preview: Real-Time AI Mastery: Voice & Smart Assistants
AI FOR DEVS
6 Course Preview: AI Fundamentals
Course Preview: AI Fundamentals
AI FOR DEVS
7 GPT-4o API: Create Your Own Talking and Listening AI Girlfriend #gpt4o #ai  #chatgpt
GPT-4o API: Create Your Own Talking and Listening AI Girlfriend #gpt4o #ai #chatgpt
AI FOR DEVS
8 Preview: Build your own YODA with MemGPT & Elevenlabs
Preview: Build your own YODA with MemGPT & Elevenlabs
AI FOR DEVS
9 Creating an Illustrated Book with GPT-4o Autogen Studio
Creating an Illustrated Book with GPT-4o Autogen Studio
AI FOR DEVS
10 NEW Claude 3.5 Sonnet API: Build a Handwriting Analyzer Web App from Scratch
NEW Claude 3.5 Sonnet API: Build a Handwriting Analyzer Web App from Scratch
AI FOR DEVS
11 Groq API: Real-Time Chatting with All Your Podcasts & MP3s
Groq API: Real-Time Chatting with All Your Podcasts & MP3s
AI FOR DEVS
12 NEW Claude 3.5 Sonnet API: Create Your Own AI Book Author & Illustrator App
NEW Claude 3.5 Sonnet API: Create Your Own AI Book Author & Illustrator App
AI FOR DEVS
Build A Talking AI Agent with Claude 3.5 Sonnet - Python Tutorial
Build A Talking AI Agent with Claude 3.5 Sonnet - Python Tutorial
AI FOR DEVS
14 NEW GPT-4o Mini API - First Impressions: Real-World Use Cases … and Why It Beats GPT-4o
NEW GPT-4o Mini API - First Impressions: Real-World Use Cases … and Why It Beats GPT-4o
AI FOR DEVS
15 Building A LinkedIn Outreach AutoGen Workforce
Building A LinkedIn Outreach AutoGen Workforce
AI FOR DEVS
16 ClaudeDev: This Mind-Blowing Coding Agent Can Build SaaS Apps in Minutes!
ClaudeDev: This Mind-Blowing Coding Agent Can Build SaaS Apps in Minutes!
AI FOR DEVS
17 Watch Me Build an AI Chat Agent Solution for a Real Client
Watch Me Build an AI Chat Agent Solution for a Real Client
AI FOR DEVS
18 Build an Insane Realistic Uncensored Image Generator App with Cursor
Build an Insane Realistic Uncensored Image Generator App with Cursor
AI FOR DEVS
19 3 Cursor Hacks to Boost Your Development Speed
3 Cursor Hacks to Boost Your Development Speed
AI FOR DEVS
20 LLAMA 3.2 Just Dropped! Let's Build a Full-Stack App with Incredible VISION
LLAMA 3.2 Just Dropped! Let's Build a Full-Stack App with Incredible VISION
AI FOR DEVS
21 Run LLAMA 3.2 Models Locally with Ollama and Open WebUI
Run LLAMA 3.2 Models Locally with Ollama and Open WebUI
AI FOR DEVS
22 OpenAI Swarm - The New Groundbreaking AI Agent Framework
OpenAI Swarm - The New Groundbreaking AI Agent Framework
AI FOR DEVS
23 Enhancing OpenAI Swarm Agents with Real Business Data and Email Integration
Enhancing OpenAI Swarm Agents with Real Business Data and Email Integration
AI FOR DEVS
24 Building an OpenAI o1 Clone with Nemotron
Building an OpenAI o1 Clone with Nemotron
AI FOR DEVS
25 Building an OpenAI o1 Clone with Nemotron, RunPod, and Open WebUI
Building an OpenAI o1 Clone with Nemotron, RunPod, and Open WebUI
AI FOR DEVS
26 GROK 2: The Power—and Danger—of Uncensored AI
GROK 2: The Power—and Danger—of Uncensored AI
AI FOR DEVS
27 Magentic One: Microsoft’s Revolutionary Multi-Agent AI System
Magentic One: Microsoft’s Revolutionary Multi-Agent AI System
AI FOR DEVS
28 Building and Tracking AI Agents with LangChain and LangSmith
Building and Tracking AI Agents with LangChain and LangSmith
AI FOR DEVS
29 NEW Model Context Protocol Revolutionizes AI Database Access
NEW Model Context Protocol Revolutionizes AI Database Access
AI FOR DEVS
30 Claude MCP Step-by-Step: AI + Files + Search + Databases = Magic!
Claude MCP Step-by-Step: AI + Files + Search + Databases = Magic!
AI FOR DEVS
31 Claude MCP Step-by-Step: AI + Files + Search + Databases = Magic!
Claude MCP Step-by-Step: AI + Files + Search + Databases = Magic!
AI FOR DEVS
32 Magentic One: Microsoft’s Revolutionary Multi-Agent AI System
Magentic One: Microsoft’s Revolutionary Multi-Agent AI System
AI FOR DEVS
33 Turn Claude Into Your Ultimate AI Hub – Connect Anything with Custom MCP Servers!
Turn Claude Into Your Ultimate AI Hub – Connect Anything with Custom MCP Servers!
AI FOR DEVS
34 Build A Human-Like AI Agent That Feels Shockingly Real with Gemini 2.0 Flash API
Build A Human-Like AI Agent That Feels Shockingly Real with Gemini 2.0 Flash API
AI FOR DEVS
35 Build Real-World Apps with DeepSeek V3: 98% Cheaper & Better Than GPT
Build Real-World Apps with DeepSeek V3: 98% Cheaper & Better Than GPT
AI FOR DEVS
36 Build a Talking Smarter-Than-You AI Girlfriend (DeepSeek R1 Tutorial)
Build a Talking Smarter-Than-You AI Girlfriend (DeepSeek R1 Tutorial)
AI FOR DEVS
37 This AI Girlfriend is Smarter Than You (And She’s Not Nice) - DeepSeek R1 Tutorial
This AI Girlfriend is Smarter Than You (And She’s Not Nice) - DeepSeek R1 Tutorial
AI FOR DEVS
38 NEW Gemini 2.0 EXP is MIND-BLOWING: Create Children's Stories with YOUR CHARACTERS (API Tutorial)
NEW Gemini 2.0 EXP is MIND-BLOWING: Create Children's Stories with YOUR CHARACTERS (API Tutorial)
AI FOR DEVS
39 Gemini 2.5 Pro + Cursor + Custom MCP Server: The ULTIMATE AI Powerhouse!
Gemini 2.5 Pro + Cursor + Custom MCP Server: The ULTIMATE AI Powerhouse!
AI FOR DEVS
40 Manus AI: Building a Profitable AI Business from Scratch in 45 Min
Manus AI: Building a Profitable AI Business from Scratch in 45 Min
AI FOR DEVS
41 Run LLaMA 4 at Lightning Speed (Almost Free!)
Run LLaMA 4 at Lightning Speed (Almost Free!)
AI FOR DEVS
42 Coding Showdown: Building A Learning App - GPT-4.1 vs Sonnet 3.7
Coding Showdown: Building A Learning App - GPT-4.1 vs Sonnet 3.7
AI FOR DEVS
43 Is GPT 4.1 in Cursor the NEW KING? 👑 Coding Challenge vs Claude 3.7 Sonnet
Is GPT 4.1 in Cursor the NEW KING? 👑 Coding Challenge vs Claude 3.7 Sonnet
AI FOR DEVS
44 Build Your Own Video SaaS in Minutes with OpenAI Codex
Build Your Own Video SaaS in Minutes with OpenAI Codex
AI FOR DEVS
45 Build an AI Skin Improver SaaS with Cursor & MCP
Build an AI Skin Improver SaaS with Cursor & MCP
AI FOR DEVS
46 Einführung in LLMOps - Best Practices für Betrieb von LLMs
Einführung in LLMOps - Best Practices für Betrieb von LLMs
AI FOR DEVS

This video tutorial demonstrates how to build a talking AI agent using Claude 3.5 Sonnet and Python, with a focus on function calling for external tasks and equipping the AI model with abilities like email checking and calendar access. The project provides a comprehensive guide on building a stereotypical nagging mother AI agent that reminds users of tasks, chores, and self-care routines in a humorous manner. By following this tutorial, viewers can learn how to develop a conversational AI system

Key Takeaways
  1. Set up a virtual environment to separate dependencies
  2. Activate the environment and create a file named app.py
  3. Install Anthropics and Pame
  4. Import Anthropics and create an Anthropics client
  5. Create a system prompt for the AI agent
  6. Create an anthropic client to communicate with the anthropic API
  7. Store the entire conversation in a variable called conversation
  8. Use Claude 3.5 Sonnet and provide a prepared mother AI prompt as the system prompt and user prompt
  9. Extract the response from anthropic's Return result and output it directly to the console
  10. Use 11 Labs to output the text to speech
💡 The key insight from this tutorial is that function calling for external tasks and equipping the AI model with abilities like email checking and calendar access can significantly improve the performance and conversational capabilities of a talking AI agent.

Related Reads

📰
Let Me Show You Which AI Model Actually Writes the Best Code
Learn which AI model writes the best code and how to evaluate them for coding tasks, saving time and resources
Dev.to · gentlenode
📰
What Actually Happens When You Press Enter in ChatGPT?
Discover what happens when you press Enter in ChatGPT and learn about the underlying AI technology
Medium · AI
📰
What Actually Happens When You Press Enter in ChatGPT?
Discover what happens when you press Enter in ChatGPT and how it processes your input
Medium · Machine Learning
📰
I Built an AI-Powered LeetCode Auto Solver Chrome Extension (Using JavaScript + LLM APIs)
Learn how to build a Chrome extension that uses LLM APIs to automatically solve LeetCode problems, and discover the potential of AI-powered coding tools
Medium · LLM
Up next
5 Levels of AI Agents - From Simple LLM Calls to Multi-Agent Systems
Dave Ebbelaar (LLM Eng)
Watch →