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.0a2.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

mpaia-0.1.0a2-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file mpaia-0.1.0a2.tar.gz.

File metadata

  • Download URL: mpaia-0.1.0a2.tar.gz
  • Upload date:
  • Size: 8.0 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.0a2.tar.gz
Algorithm Hash digest
SHA256 c01e14ee085f297ed4e1936235cbe7734bf6184ac36e22d12e76059d4079f671
MD5 12856bcbbc95d1373570a44078493900
BLAKE2b-256 8a27faca98f72bac9b9fc489664d9e912a9da275c937852161103b211320bc83

See more details on using hashes here.

File details

Details for the file mpaia-0.1.0a2-py3-none-any.whl.

File metadata

  • Download URL: mpaia-0.1.0a2-py3-none-any.whl
  • Upload date:
  • Size: 8.2 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.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 0cf0982c10a7ee11b31aca17c334ebfcfe4dde1d5b6ead443cc5feb3efd717fb
MD5 7f545783c7d9fff5d8616cc7f716470d
BLAKE2b-256 f2ace0dcb6d76b1fd4159c0d091c19af2a314a4a8963db9da959f1c3a1387ee4

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