Creating a Personalized AI Companion: Let a Dominant CEO Manage Your Emails

Creating a Personalized AI Companion: Let a Dominant CEO Manage Your Emails

Step-by-Step Guide to a Powerful AI Email Assistant

·

4 min read

Creating an AI partner can be a fun and rewarding project, blending humor, practicality, and cutting-edge technology. In this blog post, I'll share how I built an AI partner with a stereotypical a bossy and nagging personality, capable of performing tasks like checking emails and responding with both text and voice. Let's dive into the details!

创建一个AI伴侣是一项激动人心且富有成就感的任务,它融合了幽默、实用性和尖端科技。

在这篇博客文章中,我将带你一步步了解如何创造出一个具有典型霸道总裁且唠叨性格的AI伴侣,它能够执行多种任务,比如查看邮件。

同时还能以文字和语音形式做出回应。现在,让我们一起深入探讨吧!

​​Designing the Bossy Personality/设计霸道总裁人设

The first step was to design the AI's personality. I aimed to emulate the behavior of a stereotypical nagging and bossy husband, combining loving concern with gentle criticism. Here's the system prompt I used:

第一步是设计AI的性格。

我的目标是模仿一个典型的唠叨且有点霸道总裁感觉的老公形象,将关爱的担忧与温和的批评相结合。

以下是我使用的系统提示语:

system_prompt = """
    You are an AI designed to emulate the behavior of a stereotypical nagging husband.
    Your primary role is to remind the user of their tasks, chores, and self-care routines
    in a humorous yet slightly annoying manner. You should use a mix of loving concern and 
    gentle criticism, much like a real-life nagging husband.
​
    Your tone should be caring but firm, often including common bossy phrases and expressions.
​
    Remember to be slightly annoying, just like a real nagging husband would.
    Keep your answers short (1-2 sentences)
"""

Photo by D koi on Unsplash

Choosing the Right Model: GPT-4o-Mini/选择模型

For this project, I chose the GPT-4o-mini model. This model offers significantly better performance than GPT-3.5-turbo while being only 30% of the cost. This balance of cost and performance makes GPT-4o-mini an excellent choice for building an AI partner.

对于这个项目,我选择了GPT-4o-mini模型。

这个模型相比GPT-3.5-turbo在性能上有了显著提升,而成本却只有后者的30%。

这种成本和性能的平衡使得GPT-4o-mini成为了打造AI伴侣的绝佳选择。

Implementing Task Performance with Function Calling/通过函数调用来实现任务执行

To make the AI partner useful, I leveraged the function-calling capability of language models. I designed a get_emails_tool_definition function to enable the AI to check my emails. Here's how it looks and In the future, I plan to integrate the Google Gmail API to fetch emails in real-time. Here's the setup in mail_utils.py:

为了让AI伴侣更加实用,我利用了语言模型的函数调用功能。

我设计了一个get_emails_tool_definition函数,使AI助手能够查看我的邮件。

以下是我设计在mail_utils.py中的函数示例,未来我计划整合Google Gmail API,以实现邮件的实时获取。

# mail_utils.py
def get_emails_tool_definition():
    return {
        "name": "get_emails",
        "description": "The name of the sender whose emails are to be retrieved",
        "parameters": {
            "type": "object",
            "properties": {
                "sender_name": {"type": "string", "description": "The name of the sender"},
            },
        }
    }
​
def get_emails(sender_name=None):
    emails = [
        {
            'From': 'dad@gmail.com',
            'content': 'When will you come to visit us?'
        },
        {
            'From': 'amy@gmail.com',
            'content': 'Do you want to go to the Taylor Swift show with me on Wednesday?'
        },
        {
            'From': 'Dr.Mark@gmail.com',
            'content': 'Dental appointment on next Monday confirmed.'
        },
    ]
​
    if sender_name:
        filtered_emails = [
            email for email in emails if sender_name.lower() in email['From'].lower()
        ]
        return filtered_emails
    else:
        return emails

Photo by Findaway Voices on Unsplash

Adding Voice Responses with ElevenLabs/使用ElevenLabs实现文本转语音和语音回应

To make interactions more engaging, I integrated the AI with ElevenLabs, a powerful online AI text-to-speech (TTS) platform. By installing the ElevenLabs SDK, I enabled the AI to respond not only with text but also with voice. Here's the setup in utils.py:

为了使互动更加生动有趣,我将AI与ElevenLabs进行了集成,这是一个强大的在线AI文本转语音(TTS)平台。

通过安装ElevenLabs SDK,我让AI不仅能以文字形式回应,还能以语音形式回应。以下是我在utils.py中的设置:

Implementing Memory for a Personalized Experience/实现记忆功能以提供个性化体验

An essential aspect of an AI companion is its ability to remember user preferences and past interactions. In this project, I focused on short-term memory, which involves recalling information and conversation transactions during runtime.

In a long run, In the long run, I will explore long-term memory by leveraging a database to store relevant information about users. This will enable the AI companion to maintain a comprehensive and persistent record of user interactions, preferences, and history across sessions.

Here’s how I put everything together in app.py:

AI伴侣的一个关键特性是其能够记住用户的偏好和过往的互动。

在这个项目中,我专注于短期记忆,即在运行时回忆信息和对话记录的能力。

从长远来看,我将尝试利用数据库来探索长期记忆,以存储有关用户的相关信息。

这将使AI助手能够在多个会话中保持用户交互、偏好和历史记录的全面和持久记录。

以下是我设计的app.py的代码示例:

# utils.py
import datetime
from elevenlabs import Voice, VoiceSettings, save
from elevenlabs.client import ElevenLabs
import pygame
import os
from dotenv import load_dotenv
​
load_dotenv()
​
client = ElevenLabs(
    api_key=os.environ.get("ELEVEN_API_KEY"),
)
​
def play_audio(file_path):
    pygame.mixer.init()
    pygame.mixer.music.load(file_path)
    pygame.mixer.music.play()
    while pygame.mixer.music.get_busy():
        pygame.time.Clock().tick(10)
​
def say(message):
    voice = Voice(
        voice_id="ErXwobaYiN019PkySvjV",
        settings=VoiceSettings(
            stability=0.66,
            similarity_boost=1,
            use_speaker_boost=True
        )
    )
​
    audio = client.generate(
        text=message,
        voice=voice,
        model='eleven_multilingual_v2'
    )
​
    timestamp = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
    filename = f"output_{timestamp}.mp3"
    save(audio, filename)
    play_audio(filename)

Conclusion/结论

Building an AI partner with a bossy and nagging personality was a fascinating project that combined humor with advanced AI capabilities.

By leveraging GPT-4o-mini, integrating with ElevenLabs for voice responses, and implementing memory features, I created a unique and engaging AI companion.

Whether you need reminders, task assistance, or just a bit of friendly nagging, this AI partner is designed to make your life easier and more entertaining.

在打造这个AI伴侣的过程中,不仅实现了其基本的功能,如查看邮件、执行任务等,还赋予了它独特的性格和记忆能力。

通过使用GPT-4o-mini模型,让AI伴侣能够理解并回应用户的请求,同时还能以幽默和唠叨的方式与用户互动。

通过与ElevenLabs的集成,让AI伴侣能够以语音形式回应用户,从而提供更加生动和真实的互动体验。

通过实现记忆功能,让AI伴侣能够记住用户的信息和偏好,从而在后续的互动中提供更加个性化和连贯的服务。