Add KI/LLM integration with OpenAI-compatible API support
All checks were successful
Auto Build and Push Docker Image / build (push) Successful in 30s
All checks were successful
Auto Build and Push Docker Image / build (push) Successful in 30s
Features: - /ai setup - Setup wizard via private chat for security - /ai status - Show current config (API key masked) - /ai on/off - Enable/disable AI per chat - /ai random <1-10> - Set random trigger probability (admins) - /ai help - Detailed help - /ask-ai [text] - Generate AI response Security: - API keys only entered in private chat - API keys masked in status display - Admin-only configuration Architecture: - OpenAI-compatible client (OpenAI, Ollama, OpenRouter) - Global system prompt (.env) + group prompt (DB) - 50 message context per chat - SQLite tables: ai_settings, message_context, setup_sessions Defaults: - AI disabled by default - Trigger word: ask-ai - Random probability: 1% Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
80
README.md
80
README.md
@@ -1,6 +1,6 @@
|
||||
# Ulfbot
|
||||
|
||||
Ein Telegram-Bot, der mithilfe von Markov Chains neue Sätze aus vorherigen Nachrichten generiert.
|
||||
Ein Telegram-Bot, der mithilfe von Markov Chains neue Sätze aus vorherigen Nachrichten generiert. Optional mit KI/LLM-Integration.
|
||||
|
||||
## Features
|
||||
|
||||
@@ -8,6 +8,7 @@ Ein Telegram-Bot, der mithilfe von Markov Chains neue Sätze aus vorherigen Nach
|
||||
- Generiert grammatikalisch sinnvolle Sätze mit Trigrammen
|
||||
- Antwortet bei Reply, Erwähnung (@username) oder zufällig
|
||||
- Pro-Chat-Wahrscheinlichkeit einstellbar (Admins)
|
||||
- **KI/LLM-Integration** (OpenAI, Ollama, OpenRouter, etc.)
|
||||
- Persistente SQLite-Datenbank
|
||||
- Docker-Support
|
||||
|
||||
@@ -62,6 +63,8 @@ npm run dev # Hot-Reload aktiv
|
||||
|
||||
## Befehle
|
||||
|
||||
### Markov (Standard)
|
||||
|
||||
| Befehl | Beschreibung |
|
||||
|--------|--------------|
|
||||
| `/start` | Begrüßung anzeigen |
|
||||
@@ -70,19 +73,75 @@ npm run dev # Hot-Reload aktiv
|
||||
| `/setprob <0-100>` | Wahrscheinlichkeit setzen (Admins) |
|
||||
| `/cleanup` | Datenbank bereinigen (Admins) |
|
||||
|
||||
### KI/LLM
|
||||
|
||||
| Befehl | Beschreibung |
|
||||
|--------|--------------|
|
||||
| `/ai setup` | KI-Setup starten (Admins, Privat-Chat) |
|
||||
| `/ai status` | Aktuelle KI-Konfiguration |
|
||||
| `/ai on/off` | KI aktivieren/deaktivieren |
|
||||
| `/ask-ai [text]` | KI-Antwort generieren |
|
||||
|
||||
## Trigger für Antworten
|
||||
|
||||
Der Bot antwortet wenn:
|
||||
- Auf eine seiner Nachrichten geantwortet wird (Reply)
|
||||
- Sein @Username erwähnt wird
|
||||
- Zufällig (basierend auf eingestellter Wahrscheinlichkeit)
|
||||
### Markov (Standard)
|
||||
- Reply auf Bot-Nachricht
|
||||
- @Username-Erwähnung
|
||||
- Zufällig (einstellbare Wahrscheinlichkeit)
|
||||
|
||||
In privaten Chats antwortet er immer.
|
||||
### KI/LLM
|
||||
- `/ask-ai [text]` Command
|
||||
- Konfigurierbares Triggerwort (z.B. `ask-ai`)
|
||||
- Zufällig (einstellbare Wahrscheinlichkeit)
|
||||
|
||||
## KI-Integration
|
||||
|
||||
### Setup
|
||||
|
||||
1. `/ai setup` in einer Gruppe ausführen
|
||||
2. Der Bot sendet eine private Nachricht mit Setup-Wizard
|
||||
3. Provider, API-Key, Model konfigurieren
|
||||
4. API-Keys werden sicher gespeichert und maskiert angezeigt
|
||||
|
||||
### Unterstützte Provider
|
||||
|
||||
| Provider | API-Format |
|
||||
|----------|------------|
|
||||
| OpenAI | OpenAI API |
|
||||
| Ollama | OpenAI-kompatibel (lokal) |
|
||||
| OpenRouter | OpenAI-kompatibel |
|
||||
| Custom | OpenAI-kompatibel |
|
||||
|
||||
### Umgebungsvariablen (.env)
|
||||
|
||||
```env
|
||||
# Bot Token (erforderlich)
|
||||
BOT_TOKEN=your_telegram_bot_token
|
||||
|
||||
# KI/LLM Settings (optional)
|
||||
AI_DEFAULT_API_KEY=your_openai_api_key
|
||||
AI_DEFAULT_BASE_URL=https://api.openai.com/v1
|
||||
AI_DEFAULT_MODEL=gpt-4o-mini
|
||||
AI_SYSTEM_PROMPT=Du bist ein freundlicher Chat-Bot...
|
||||
```
|
||||
|
||||
### Prompt-System
|
||||
|
||||
- **Globaler System-Prompt** (.env) - Immer aktiv
|
||||
- **Gruppen-Prompt** (pro Chat) - Ergänzt globalen Prompt
|
||||
|
||||
## Technisches
|
||||
|
||||
### Architektur
|
||||
|
||||
```
|
||||
src/
|
||||
├── index.ts # Bot-Logik, Commands, Setup-Wizard
|
||||
├── markov.ts # Markov Chain Implementation
|
||||
├── database.ts # SQLite Persistenz
|
||||
└── ai.ts # OpenAI-kompatibler Client
|
||||
```
|
||||
|
||||
- **Markov Chain** mit Trigrammen für bessere Grammatik
|
||||
- **SQLite** für persistente Speicherung
|
||||
- Pro Chat separate Daten/Lernkurve
|
||||
@@ -94,15 +153,6 @@ In privaten Chats antwortet er immer.
|
||||
- Limitiert auf 10.000 Übergänge pro Chat
|
||||
- Schützt neue Chats (min. 100 Übergänge nötig)
|
||||
|
||||
### Projektstruktur
|
||||
|
||||
```
|
||||
src/
|
||||
├── index.ts # Bot-Logik, Commands
|
||||
├── markov.ts # Markov Chain Implementation
|
||||
└── database.ts # SQLite Persistenz
|
||||
```
|
||||
|
||||
## Lizenz
|
||||
|
||||
ISC
|
||||
Reference in New Issue
Block a user