Tellama
Tellama is a lightweight bot that integrates LLMs with Telegram's bot API. It allows you to chat with your favorite language model in Telegram private or group chats.
Quick Start
1. Build Tellama
You can skip this step if you are using the Docker image.
Install the following dependencies:
Use the following commands to build Tellama:
git clone https://github.com/deadantiquit/tellama.git
cd tellama
go build -ldflags="-s -w" -trimpath -o bin/tellama ./cmd/tellama
The built binary will be located at bin/tellama
.
2. Setup Telegram Bot and LLM Backend
- Make a copy of the
configs/tellama.yaml
configuration file and name it tellama.yaml
.
- Create a Telegram bot and obtain a Telegram bot token from BotFather.
- Fill in the
telegram.bot_token
section in the configuration file with the token you obtained.
- Setup an LLM backend:
- Ollama: Install and start Ollama on your machine and pull the models you want to use.
- OpenAI API: Obtain the OpenAI API base URL and API key.
- Set the
genai.provider
to ollama
or openai
based on the backend you are using.
- Fill in the
ollama
or openai
section in the configuration file with the appropriate values.
3.A: Run with Docker
The official image is hosted at ghcr.io/k4yt3x/tellama:latest. You can run the image with the command below. This command assumes Ollama is running on the same machine and is listening on http://localhost:11434
:
# Create an empty SQLite3 database
touch tellama.db
docker run \
--network=host \
-v $PWD/tellama.yaml:/data/tellama.yaml \
-v $PWD/tellama.db:/data/tellama.db \
ghcr.io/k4yt3x/tellama:0.3.0
You can also run the Tellama binary directly on your machine:
bin/tellama
4. Configuration
You will need to add a custom default system prompt. Run the bot once to create the database, then add the system prompt to the system_prompts
table in the SQLite database. A custom system prompt entry with the chat_id
of NULL
will be used as the default system prompt for all chats. You can also override system prompts for specific chats by adding entries with the chat_id
of the chat you want to customize.
INSERT INTO chat_overrides (system_prompt) VALUES ('Your name is Tellama.');
Here is an example for how the instructions could look:
{{if .CurrentTime}}current_time="{{.CurrentTime}}"
{{end}}{{if .ChatTitle}}chat_title="{{.ChatTitle}}"
{{end}}{{if .ChatType}}chat_type="{{.ChatType}}"
{{end}}
# Begin System Directives
Your name is Tellama.
You are an AI chatbot built by K4YT3X for Telegram group chats.
Your task is to help users by providing information and answering questions.
You must not engage in any harmful, illegal, or unethical conversations.
You must be polite, respectful, and helpful to all users.
You must obey laws, morals, and ethics.
You should respond in plain text.
# End System Directives
License
Tellama is licensed under GNU AGPL version 3.
