Lexi is a Telegram chatbot that connects to various Large Language Models (LLMs) such as OpenAI, Groq, Ollama, KoboldCpp, and Gemini. This allows you to have conversational experiences right within your Telegram app.
- Multiple API Support: Connect to different LLM providers including OpenAI, Groq, Ollama, KoboldCpp, and Gemini.
- Customizable System Prompt: Set up a system prompt to guide the AI's responses.
- Multi-User Access: Grant or restrict access to the bot based on user ID.
- Flexible Group Chat Behavior: Configure the bot to respond to mentions only, authorized users, or all users in group chats.
- Context Handling: Maintains chat history within a session for more coherent conversations.
- Token Usage Tracking: Displays the number of tokens used per API call.
- Python 3.9 or higher
- A Telegram account
- A Telegram bot token (Create a bot using @BotFather)
- API keys (optional, but required for some APIs like OpenAI, Groq, and Gemini)
- Clone the repository:
git clone https://github.com/crim50n/lexi.git cd lexi - Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate - Install dependencies:
pip install -r requirements.txt
- Set environment variables:
export BOT_TOKEN="YOUR_TELEGRAM_BOT_TOKEN" export ADMIN_USER_ID="YOUR_TELEGRAM_USER_ID" export BOT_USERNAME="YOUR_BOT_USERNAME"
- Run the bot:
python lexi.py
- Install Termux and required packages:
pkg update pkg install python git python-pip rust
- Clone the repository:
git clone https://github.com/crim50n/lexi.git cd lexi - Create and activate a virtual environment:
python -m venv venv source venv/bin/activate - Install dependencies:
pip install -r requirements.txt
- Set environment variables:
export BOT_TOKEN="YOUR_TELEGRAM_BOT_TOKEN" export ADMIN_USER_ID="YOUR_TELEGRAM_USER_ID" export BOT_USERNAME="YOUR_BOT_USERNAME"
- Run the bot:
python lexi.py
The first time you run the bot as the administrator, use the /setup command in your Telegram chat with the bot to configure:
- API Type: Choose your LLM provider (OpenAI, Groq, Ollama, etc.).
- API Host: Use the default or provide a custom host address.
- API Key: Enter your API key (if required by the chosen provider).
- API Model: Select the specific LLM model you want to use.
/start: Start interacting with Lexi./help: Show the help message with available commands./myid: Show your Telegram ID./clearcontext: Clear the conversation context.
/setup: Configure Lexi's API settings./systemprompt: Set a system-wide prompt./model: Select a different LLM model./timeout: Set the API request timeout in seconds (0 for infinite)./adduser: Add a user by their Telegram ID./deluser: Delete a user by their Telegram ID./useraccess: Toggle bot access between all users and authorized users only./groupmode: Choose Lexi's behavior in groups (respond to mentions, authorized users, or all)./parsemode: Choose the message parsing mode (Markdown, HTML, None, Auto).
Contributions are welcome! Please feel free to submit issues and pull requests.
