ginchiee-bot / README.md
Catalna's picture
ο»Ώfeat: switch to Postgres, add intent router and a warmer persona
1fcc069
|
Raw History Blame Contribute Delete
4.64 kB

A newer version of the Gradio SDK is available: 6.32.0

Upgrade
metadata
title: Ginchiee Bot
emoji: 🌸
colorFrom: pink
colorTo: purple
sdk: gradio
app_file: app.py
app_port: 7860
pinned: false

🍎 Ginchiee β€” AI Diet Companion Bot

Bot Telegram yang membantu kamu menjaga pola makan melalui reminder cerdas, food logging, estimasi nutrisi, dan percakapan natural dengan AI.

✨ Fitur MVP

  • πŸ€– AI Conversation β€” Ngobrol natural tentang diet & pola makan
  • πŸ“ Food Logging β€” Catat makanan dengan bahasa natural
  • πŸ“Š Nutrition Tracking β€” Hitung kalori, protein, karbs, lemak otomatis
  • ⏰ Intelligent Reminder β€” Reminder makan yang personal & kontekstual
  • πŸ‘€ User Profile β€” Setup profil & target nutrisi personal
  • 🎯 Daily Progress β€” Pantau progress nutrisi harian

πŸš€ Quick Start

1. Clone & Setup

git clone <repo>
cd ginchiee-bot
python -m venv .venv
.venv\Scripts\activate        # Windows
# source .venv/bin/activate   # Linux/Mac
pip install -r requirements.txt

2. Konfigurasi

cp .env.example .env

Edit .env:

TELEGRAM_BOT_TOKEN=your_bot_token_here
GEMINI_API_KEY=your_gemini_api_key_here

Cara dapat token:

3. Jalankan

python main.py

πŸ“‹ Commands

Command Fungsi
/start Mulai & setup profil
/profile Lihat profil & target nutrisi
/today Progress nutrisi hari ini
/log [makanan] Catat makanan
/schedule Atur jadwal makan & reminder
/reminders Lihat jadwal makan
/help Bantuan

πŸ—οΈ Struktur Project

ginchiee-bot/
β”œβ”€β”€ main.py                       # Entry point
β”œβ”€β”€ config/
β”‚   └── settings.py               # Konfigurasi (fail-fast)
β”œβ”€β”€ database/
β”‚   β”œβ”€β”€ connection.py             # PostgreSQL pool (asyncpg)
β”‚   β”œβ”€β”€ migrations.py             # Migrasi berversi
β”‚   └── migrations/               # 0001_initial.sql, 0002_...
β”œβ”€β”€ nutrition/
β”‚   β”œβ”€β”€ calculator.py             # BMR/TDEE/macro calculator
β”‚   β”œβ”€β”€ food_database.py          # Database nutrisi makanan
β”‚   └── parser.py                 # NLP food parser
β”œβ”€β”€ services/
β”‚   β”œβ”€β”€ ai_service.py             # Gemini LLM abstraction
β”‚   β”œβ”€β”€ personality.py            # Persona, few-shot, sanitizer
β”‚   β”œβ”€β”€ intent_service.py          # Router intent (1 call/pesan)
β”‚   β”œβ”€β”€ nutrition_service.py       # Food logging, koreksi & hapus
β”‚   β”œβ”€β”€ reminder_service.py        # Reminder generation
β”‚   β”œβ”€β”€ scheduler_service.py       # APScheduler
β”‚   └── user_service.py            # User CRUD
β”œβ”€β”€ scripts/
β”‚   └── migrate_sqlite_to_postgres.py
β”œβ”€β”€ bot/
β”‚   β”œβ”€β”€ conversations/
β”‚   β”‚   └── onboarding.py         # Multi-step registration
β”‚   └── handlers/
β”‚       β”œβ”€β”€ activity_handler.py
β”‚       β”œβ”€β”€ food_handler.py
β”‚       β”œβ”€β”€ help_handler.py
β”‚       β”œβ”€β”€ message_handler.py     # Router + konfirmasi
β”‚       β”œβ”€β”€ photo_handler.py
β”‚       β”œβ”€β”€ profile_handler.py
β”‚       β”œβ”€β”€ schedule_handler.py
β”‚       └── today_handler.py
└── tests/
    β”œβ”€β”€ test_database.py          # Migrasi, wrapper, SQL nyata
    β”œβ”€β”€ test_personality.py       # Sanitizer & gaya bicara
    β”œβ”€β”€ test_intent_router.py     # Parser intent
    └── test_huggingface_runtime.py

πŸ”§ Stack

  • Python 3.11+
  • python-telegram-bot β€” Telegram handler
  • Google Gemini β€” LLM (persona + JSON-mode router)
  • PostgreSQL + asyncpg β€” Database (Neon / Supabase / lokal)
  • APScheduler β€” Meal & activity reminder scheduler
  • Migrasi berversi β€” database/migrations/NNN_*.sql, idempotent per boot

βš™οΈ Konfigurasi

Env Wajib Isi
TELEGRAM_BOT_TOKEN βœ… Token dari @BotFather
GEMINI_API_KEY βœ… API key Google AI Studio
DATABASE_URL βœ… Connection string Postgres
ALLOWED_USER_IDS β€” Batasi bot ke user id tertentu (koma)
AI_TEMPERATURE β€” Default 0.95
GEMINI_MODEL β€” Default gemini-flash-lite-latest

Di Hugging Face, set variabel ini di Settings β†’ Variables and secrets, bukan memakai file .env.

⚠️ Disclaimer

Ginchiee adalah AI companion, bukan dokter atau ahli gizi. Semua estimasi nutrisi bersifat perkiraan. Konsultasikan ke profesional kesehatan untuk saran medis.