2025-05-06 00:54:41 +02:00
2025-05-06 00:54:12 +02:00
2025-05-06 00:54:12 +02:00
2025-05-06 00:33:17 +02:00
2025-05-06 00:54:41 +02:00
2025-05-06 00:54:12 +02: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

  1. Clone the repository
  2. 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.
    
  3. Install dependencies:
    pip install -r requirements.txt
    
  4. Make sure Ollama is running and the specified model is available

Usage

  1. Start the bot:
    python src/main.py
    
  2. Open Telegram and start a conversation with your bot
  3. Use the /start command to begin
  4. 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 Ollama
  • src/managers/telegram_bot.py: Manages the Telegram bot functionality
  • src/memory/memory_manager.py: Handles user conversation history
  • src/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
No description provided
Readme
Languages
Python 100%