A Generative AI–Powered Telegram Companion Bot for Lonely Seniors in Singapore, leveraging the Sea‑Lion
open‑source LLM via API and LangChain
for context‑aware, empathetic conversations.
GPT Advisor is a lightweight, scalable Python application that integrates with Telegram to provide senior users with:
Friendly, engaging conversations for emotional support.
Practical daily‑life guidance (health tips, simple recipes, reminders).
Technology assistance (step‑by‑step instructions).
Local recommendations (community events, cultural facts).
Powered by the Sea‑Lion API (model: aisingapore/Gemma-SEA-LION-v3-9B-IT) and LangChain prompt templates, the bot detects conversational context and tailors responses for maximum clarity and warmth.
Context Detection: Classifies user queries into categories (e.g., Daily Life, Health, Emotional Support) using keyword‑based or ML‑based intent detection.
Prompt Engineering: Uses LangChain to format rich, context‑specific prompts for the LLM.
Sea‑Lion API Integration: Fetches responses from a local‑style open‑source LLM via HTTPS.
Session Management: Persists user context in an SQLite database (sessions.db) for continuity across chats.
Test Suite: Comprehensive pytest tests for utilities, session storage, prompt formatting, and API integration.
Python 3.8+
Telegram Bot Token (via BotFather)
Sea‑Lion API Key (sign up at https://sea-lion.ai)
Clone the repo
git clone https://github.com/your-org/gpt-advisor-bot.git
cd gpt-advisor-bot
Create & activate virtual environment
python -m venv venv
source venv/bin/activate # Linux/macOS
venv\Scripts\activate # Windows
Install dependencies
pip install -r requirements.txt
Create .env file in project root:
TELEGRAM_TOKEN=<your-telegram-bot-token>
SEA_LION_API_KEY=<your-sea-lion-api-key>
Initialize the database (creates sessions.db):
python -c "from app.session_db import init_db; init_db()"
Run the bot:
python -m app.telegram_bot
Chat on Telegram:
Search for your bot’s username and send messages.
The bot auto‑detects context, formats prompts, and replies with AI‑generated responses.
Run all tests with pytest:
pytest --maxfail=1 --disable-warnings -q
Test coverage includes:
-
Context detection (utils.detect_context)
-
Session management (session_db)
-
Prompt formatting (langchain_prompts.format_prompt)
-
API integration (sea_lion_api.generate_response)
Fork the repository and create a feature branch.
Write clear, concise code and documentation.
Add tests for new features or bug fixes.
Submit a pull request and link any relevant issues.
This project is open‑source under the MIT License.