Introducing the Ultimate AI Role-Playing Companion for Telegram


In the ever-evolving landscape of artificial intelligence and interactive entertainment, we are thrilled to unveil a powerful and deeply engaging AI Role-Playing Companion for Telegram. This bot is more than just a chatbot; it's a sophisticated platform for immersive, dynamic, and personalized narrative experiences. Whether you're looking to co-author a creative story, engage in deep character-driven conversations, or simply explore the capabilities of modern AI, this bot is your gateway to a new world of interactive storytelling.

Designed with flexibility and user control at its core, our AI companion allows you to tailor every aspect of your role-playing adventure. From crafting unique AI personas and generating vivid scenes on the fly to maintaining long-term conversational memory, the possibilities are limited only by your imagination. For the technically inclined, the bot also includes a suite of powerful administrative tools for monitoring performance and system health, ensuring a smooth and reliable experience for all users.

Key Features at a Glance:

  • Dynamic Personas: Choose from a curated list of SFW and NSFW personas, or create your own custom AI characters with unique backstories and personalities. A "Surprise Me!" feature can even generate a completely new persona for you based on your preferences.
  • Immersive Scenery: Set the stage for your interactions by selecting from a variety of pre-defined scenes or generating a new one with a specific genre in mind, from a cozy coffee shop to a bustling cyberpunk dive bar.
  • Long-Term Memory: The bot can remember key details from your conversations, allowing for a coherent and evolving narrative over time. This feature can be toggled on or off to suit your preferences.
  • User-Centric Setup: A comprehensive setup hub allows you to define your own character's name and profile, giving the AI context for its interactions with you.
  • Real-Time Streaming: Experience the AI's thought process with real-time streaming of its responses, creating a more natural and engaging conversational flow. This feature can be toggled by the admin.
  • Admin Dashboard: For bot owners, a suite of commands provides insights into performance metrics, system status (including CPU and GPU load), and user management.
  • Robust and Asynchronous: Built with a modern Python architecture, the bot handles multiple user requests concurrently via a queuing system, ensuring responsiveness even under load.

Getting Started: A Step-by-Step Manual

This guide will walk you through the process of setting up and running your own instance of the AI Role-Playing Companion.

Prerequisites

Before you begin, ensure you have the following:

Python 3.10 or higher.
A Telegram Bot Token: You can get one by talking to the BotFather on Telegram.
LM Studio: This bot is designed to connect to a local large language model (LLM) served via LM Studio. You will need to have LM Studio running with a loaded model.

Installation and Setup
Step 1: Obtain the Project Files

First, you'll need to have all the project files from my Git repository in a single directory on your computer. These files include:

Directory - .f.e Telegram_AI_Bot
bot.py
config.py
handlers.py
db_utils.py
performance_monitor.py
system_monitor.py
log_utils.py
requirements.txt
.env.txt
Step 2: Install Dependencies

The requirements.txt file lists all the necessary Python libraries for the bot to function correctly. Open a terminal or command prompt in your project directory and run the following command to install them:

Bash

pip install -r requirements.txt

This will install the required libraries, including python-telegram-bot, openai, python-dotenv, httpx, psutil, and gputil.

Step 3: Configure Your Environment

.env file

Edit the .env file and fill in the following details:

TELEGRAM_BOT_TOKEN: Your bot token obtained from BotFather.
LM_STUDIO_API_BASE: The local API endpoint provided by LM Studio (e.g., http://localhost:1234/v1).
BOT_OWNER_ID: Your personal numeric Telegram user ID. You can get this by talking to a bot like @userinfobot.

Step 4: Load a Model in LM Studio

Launch LM Studio and download a language model of your choice. Some recommended models mentioned in the configuration are arliai_mistral-small-24b-arliai-rpmax-v1.4 and llama-3.2-1b-nsfw_sex_orca. Once the model is loaded, navigate to the "Local Server" tab and start the server.

Step 5: Run the Bot

With your environment configured and LM Studio's server running, you can now start the bot. Execute the following command in your terminal:

Bash

python bot.py

If everything is set up correctly, you will see log messages in your terminal indicating that the bot has started successfully. You can now open Telegram and start interacting with your AI companion!


A Deeper Dive into the Bot's Features

Here’s a closer look at how to use some of the bot's most powerful features:

The Setup Hub

The /setup command is your central hub for customizing your experience. From here, you can:

  • Change your character's name and profile.
  • Select an AI Persona.
  • Choose a Scene.
  • Toggle Memory.
  • Delete Data.
  • On-the-Fly Generation
  • Surprise Me! Personas: In the Persona menu, you can opt to have the AI generate a new persona for you. You'll be guided through a series of questions about the desired category, species, gender, and (for NSFW) role and fetishes.
  • Generated Scenes: Don't see a scene you like? Generate a new one by choose a genre. The AI will create a descriptive setting for your interaction.

In-Conversation Commands

  • /start: Begins a new chat and clears the previous history.
  • /regenerate: If you're not satisfied with the AI's last response, this command will prompt it to generate a new one based on your last message.
  • /clear: Wipes the current conversation history, giving you a clean slate without altering your setup.
  • /display_current_setup: Shows a summary of your current character, persona, and scene settings.

Admin Commands (for the Bot Owner)
If your user ID matches the BOT_OWNER_ID in the .env file, you have access to special commands:

  • /status: Provides an overview of the bot's operational status, including the AI service connection and system metrics like CPU and GPU load.
  • /performance: Displays key performance indicators such as uptime, total requests, average response time, and active users.
  • /disc: A powerful command to disconnect all non-admin users and clear their data, useful for system updates or maintenance.