Skip to main content

My Personal AI Assistant

Project description

MPAIA (My Personal AI Assistant)

A Python package for your personal AI assistant with Telegram integration and OpenAI capabilities.

Installation

You can install MPAIA using pip:

pip install mpaia

Alternatively, you can install from the source:

  1. Clone the repository:

    git clone https://github.com/sTomerG/mpaia.git
    cd mpaia
    
  2. Install the package:

    pip install -e .
    

Configuration

Create a .env file in the virtual environment with mpaia installed with the following content:

TELEGRAM_BOT_TOKEN=your_telegram_bot_token
OPENAI_API_KEY=your_openai_api_key
ALLOWED_CHAT_IDS=comma_separated_list_of_allowed_chat_ids
ADMIN_CHAT_ID=your_admin_chat_id

Replace the placeholders with your actual values.

Usage

  1. Create custom jobs by subclassing TelegramMessageJob in a new file called custom_jobs.py. For example:

    from mpaia.jobs import TelegramMessageJob
    from mpaia.assistant import Assistant
    
    class SalaryJob(TelegramMessageJob):
        def __init__(self, chat_id: int, assistant: Assistant):
            super().__init__(
                "0 8 1 * *",  # Run on the first day of every month at 8 AM
                "Generate a friendly reminder that it's salary day",
                chat_id,
                assistant
            )
            # Add any additional initialization here
    
        async def execute(self, bot):
            # Optionally implement your custom execution logic here
            await super().execute(bot)
    
  2. Create a run_bot.py file and run your bot:

     import asyncio
    
     from custom_jobs import SalaryJob
     from dotenv import load_dotenv
    
     from mpaia.assistant import OpenAIAssistant
     from mpaia.telegram_bot import TelegramBot
    
    
     async def run_bot():
         load_dotenv(override=True)
         assistant = OpenAIAssistant()
         bot = TelegramBot(assistant)
    
         # Add custom jobs
         if bot.allowed_chat_ids:
             for chat_id in bot.allowed_chat_ids:
                 bot.add_job(SalaryJob(chat_id, assistant))
    
         await bot.run()
    
    
     if __name__ == "__main__":
         asyncio.run(run_bot())
    
  3. Run your bot:

    python run_bot.py
    

Customization

  • To add more custom jobs, create new classes in custom_jobs.py and add them to the bot in run_bot.py.
  • Modify the OpenAIAssistant parameters in run_bot.py to change the AI model or its behavior.

Note

Ensure that your Telegram bot has the necessary permissions to send messages in the allowed chats.

For more detailed information on the MPAIA package and its components, refer to the source code and docstrings in the src/mpaia directory.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mpaia-0.1.1.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

mpaia-0.1.1-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file mpaia-0.1.1.tar.gz.

File metadata

  • Download URL: mpaia-0.1.1.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for mpaia-0.1.1.tar.gz
Algorithm Hash digest
SHA256 01d03314e1252ef55b41ef405de7d930b2407b3c3cc6478242be62dec882efe9
MD5 47fceef49552e87f6173b73a3aad5157
BLAKE2b-256 74ed122888d98a8bc6cbab8c81bde9c69f44eac7f4b9c9cfcfd554d992871fcc

See more details on using hashes here.

File details

Details for the file mpaia-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: mpaia-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for mpaia-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ee076ffeb8ae71b07f8e621018600ba01dbd9b172d52751d7a3451dcd2b361cc
MD5 b23a3e3882c4f4db5abea3dd6a37884d
BLAKE2b-256 cd05bd0e54a32ae4b465dc8802ee5f1eb6523082b58acc96259cbe62865a83a2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page