mirror of
https://github.com/tcsenpai/telelama.git
synced 2025-06-01 01:20:03 +00:00
TeleLama - Telegram Bot with Ollama Integration
A Telegram bot that allows users to interact with Ollama models through a conversational interface with support for multiple conversations and system prompts.
Features
- Integration with Ollama models
- Multiple conversations per user
- Persistent conversation memory for each conversation
- Customizable system prompts per conversation
- Support for text files (PDF, TXT, HTML, JSON, Markdown, CSV)
- Image analysis (if model supports vision)
- Simple and intuitive interface
- Configurable through environment variables
Setup
- Clone the repository
- Create a
.env
file with the following variables:# Telegram Bot Configuration TELEGRAM_BOT_TOKEN=your_telegram_bot_token # Ollama Configuration OLLAMA_URL=http://localhost:11434 OLLAMA_MODEL=llama2 # Memory Configuration MEMORY_DIR=./memory # Default System Prompt DEFAULT_SYSTEM_PROMPT=You are a helpful AI assistant.
- Install dependencies:
pip install -r requirements.txt
- Make sure Ollama is running and the specified model is available
Usage
- Start the bot:
python src/main.py
- Open Telegram and start a conversation with your bot
- Use the
/start
command to begin - Use
/help
to see all available commands
Available Commands
Conversation Management
/conv [number]
- Switch to conversation/conv
- List all conversations/renameconv [number] [title]
- Rename a conversation/reset [number]
- Reset a conversation (preserves system prompt)
System Prompt
/sysprompt [number] [prompt]
- Set system prompt/sysprompt [number]
- View system prompt
Help
/help
- Show all available commands
File Support
The bot can process the following file types:
- Text files (.txt)
- PDF documents (.pdf)
- HTML files (.html)
- JSON files (.json)
- Markdown files (.md)
- CSV files (.csv)
Image Support
If your Ollama model supports vision capabilities, you can send images for analysis.
Project Structure
src/connectors/ollama_connector.py
: Handles communication with Ollamasrc/managers/telegram_bot.py
: Manages the Telegram bot functionalitysrc/memory/memory_manager.py
: Handles user conversation historysrc/main.py
: Entry point of the application
Requirements
- Python 3.7+
- Ollama running locally
- Telegram Bot Token
- Required Python packages (see requirements.txt)
Memory Structure
Each user's conversations are stored in JSON files with the following structure:
{
"conversations": {
"0": {
"messages": [
{
"role": "user",
"content": "message content",
"timestamp": "ISO timestamp"
}
],
"title": "conversation title",
"system_prompt": "system prompt"
}
}
}
Description
Languages
Python
100%