Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Telegram AI bot using Ollama

Python Ollama Telegram

Powered by Ollama and python-telegram-bot


✨ Features

  • Local Processing: Your data stays on your machine. No cloud API subscriptions required.
  • Persistent History: Automatically saves conversation history per user.
  • Configurable: Easily swap models, adjust context windows, or change history depth.
  • Type Awareness: Displays a "typing..." status while the AI is thinking.

Setup

  1. Install Ollama from ollama.com/download.
  2. Pull a model using ollama pull <model_name>.
    • For example: ollama pull gemma3
  3. Pip install
    pip install -r requirements.txt
  4. Rename .env.copy to .env
    mv .env.copy .env
  5. Fill in your Telegram bot token in .env

Checklist:

  1. The .env file has the right bot token. Run /newbot at: t.me/botfather
  2. The .env file has a model that you have downloaded (check with ollama ls)

  1. Run bot.py
    python bot.py

Environment Variables

You can customize the behavior by editing the .env file:

Variable Description Default
TELEGRAM_BOT_TOKEN Your unique Bot API token. Required
OLLAMA_MODEL The model name (must be downloaded). gemma3
MAX_HISTORY Number of messages to remember for context. 10
CONTEXT_WINDOW The num_ctx passed to Ollama. 2048
KEEP_ALIVE How long to keep the model in memory. -1 (infinite)

📜 License

This project is licensed under the MIT License. See the LICENSE file for more details.

About

Telegram AI bot using Ollama

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages