Skip to content

Latest commit

ย 

History

46 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Bite.ai Logo

Bite.ai

AI-Powered Voice Food Assistant
Ask about any food. Scan any barcode. Get instant nutritional verdicts.

Python 3.11 FastAPI Ollama Powered by Oumi MIT License


๐Ÿ“ธ Screenshots

Home Screen Voice Call Mode Barcode Scanner
Home Voice Barcode
Analysis Result Profile Setup Mobile View
Result Profile Mobile

๐ŸŽฌ Demo Video

[Watch the Demo]


โœจ Features

  • ๐ŸŽ™๏ธ Voice Call Mode โ€” Tap the orb or mic to start a continuous voice conversation. Bite.ai listens, processes, speaks back, and auto-listens again โ€” like a real phone call.
  • ๐Ÿ“ท Barcode Scanner โ€” Scan any product barcode using your phone camera (supports multiple cameras) or type it manually. Fetches real nutrition data from Open Food Facts.
  • ๐Ÿง  Hybrid Analysis Engine โ€” Rule-based analyzer delivers instant, accurate verdicts. Ollama-hosted SLM provides natural language enhancement as a fallback.
  • ๐Ÿ‘ค Personalized Profiles โ€” Set your allergies (peanut, lactose, gluten, fish, soy), health conditions (diabetes, hypertension, cholesterol), and dietary preferences for tailored advice.
  • ๐Ÿ”ฎ Interactive 3D Orb โ€” A living, breathing Three.js orb that changes color and animation based on state: idle โ†’ listening โ†’ processing โ†’ speaking โ†’ verdict (eat/avoid/sometimes).
  • ๐Ÿ“ฑ Mobile-First Design โ€” Fully responsive, works on phone browsers over local WiFi. Camera, voice, and touch โ€” all native.
  • ๐Ÿ—ฃ๏ธ Browser TTS/STT โ€” No external APIs needed. Uses the Web Speech API for speech recognition and synthesis, with automatic voice selection for natural output.

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                  CLIENT (Browser)                 โ”‚
โ”‚  Voice (STT) โ”€โ”€โ–ถ Text Input โ”€โ”€โ–ถ TTS (Speak)      โ”‚
โ”‚  Barcode Camera โ”€โ”€โ–ถ Manual Entry                  โ”‚
โ”‚  3D Orb (Three.js) โ”€โ”€โ–ถ State Visualization        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                        โ”‚ HTTP POST /query
                        โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚               GATEWAY (FastAPI)                   โ”‚
โ”‚  Intent Classifier โ”€โ”€โ–ถ Rules Layer + Router       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚          โ”‚          โ”‚
       โ–ผ          โ–ผ          โ–ผ
  BARCODE     FOOD QUERY   CASUAL
  (OFF API)   (INDB 1014   (Templates)
               foods)
       โ”‚          โ”‚
       โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜
            โ–ผ
   AGENT 1: Rule-Based Analyzer
   (Instant nutritional verdicts)
            โ”‚
            โ–ผ
   AGENT 2: Response Generator
   (Templates primary + Ollama SLM fallback)
            โ”‚
            โ–ผ
       Browser TTS

Two-Agent Pipeline

Agent Role Technology Latency
Agent 1 โ€” Analysis Nutritional verdict (eat/avoid/sometimes) Rule-based engine + Ollama SLM ~5ms (rules) / ~1.2s (SLM)
Agent 2 โ€” Response Natural language generation Templates (primary) + Ollama SLM ~1ms (template) / ~1.3s (SLM)

๐Ÿ“ Project Structure

bite.ai/
โ”œโ”€โ”€ app/                          # FastAPI backend
โ”‚   โ”œโ”€โ”€ main.py                   # App entry point, routes, lifespan
โ”‚   โ”œโ”€โ”€ models/                   # Pydantic schemas
โ”‚   โ””โ”€โ”€ services/
โ”‚       โ”œโ”€โ”€ intent.py             # Intent classifier (Rules + Router)
โ”‚       โ”œโ”€โ”€ resolver.py           # Food resolver (INDB Excel โ†’ fuzzy match)
โ”‚       โ”œโ”€โ”€ analyzer.py           # Agent 1: Hybrid rule-based + SLM analyzer
โ”‚       โ”œโ”€โ”€ barcode.py            # Open Food Facts API client
โ”‚       โ”œโ”€โ”€ response.py           # Template-based response formatter
โ”‚       โ””โ”€โ”€ response_agent.py     # Agent 2: Template + Ollama SLM responses
โ”‚
โ”œโ”€โ”€ frontend/                     # Browser-based UI
โ”‚   โ”œโ”€โ”€ index.html                # Single-page app
โ”‚   โ”œโ”€โ”€ styles.css                # Design system (warm aesthetic)
โ”‚   โ”œโ”€โ”€ app.js                    # Voice agent, API calls, UI logic
โ”‚   โ”œโ”€โ”€ orb.js                    # Three.js 3D orb with state animations
โ”‚   โ””โ”€โ”€ logo.png                  # App logo / favicon
โ”‚
โ”œโ”€โ”€ data/                         # Datasets
โ”‚   โ”œโ”€โ”€ INDB_data.xlsx            # Indian Nutrient Database (1014 foods)
โ”‚   โ””โ”€โ”€ training_data.jsonl       # Fine-tuning dataset
โ”‚
โ”œโ”€โ”€ docs/                         # Architecture & design docs
โ”‚   โ”œโ”€โ”€ 01_architecture.md
โ”‚   โ”œโ”€โ”€ 02_intent_classification.md
โ”‚   โ”œโ”€โ”€ 03_barcode_flow.md
โ”‚   โ”œโ”€โ”€ 04_nonbarcode_flow.md
โ”‚   โ”œโ”€โ”€ 05_unified_schema_and_agent.md
โ”‚   โ”œโ”€โ”€ 06_dataset_design.md
โ”‚   โ”œโ”€โ”€ 07_finetuning_and_inference.md
โ”‚   โ”œโ”€โ”€ 08_conversation_and_optimization.md
โ”‚   โ””โ”€โ”€ 09_backend_and_failure_handling.md
โ”‚
โ”œโ”€โ”€ notebooks/                    # Training notebooks
โ”‚   โ””โ”€โ”€ colab_train.py            # Google Colab fine-tuning script
โ”‚
โ”œโ”€โ”€ scripts/                      # Utility scripts
โ”‚   โ”œโ”€โ”€ generate_dataset.py       # Dataset augmentation
โ”‚   โ””โ”€โ”€ generate_dataset_fin.py   # Final dataset generator
โ”‚
โ”œโ”€โ”€ configs/                      # Configuration files
โ”œโ”€โ”€ requirements.txt              # Python dependencies
โ””โ”€โ”€ README.md                     # โ† You are here

๐Ÿš€ Getting Started

Prerequisites

  • Python 3.11 โ€” Download
  • Ollama โ€” Download (for SLM inference)
  • Chrome/Edge โ€” Required for voice features (Web Speech API)

1. Clone & Install

git clone https://github.com/your-username/bite-ai.git
cd bite-ai

# Create virtual environment
python -m venv venv
venv\Scripts\activate        # Windows
# source venv/bin/activate   # Linux/macOS

# Install dependencies
pip install -r requirements.txt

2. Setup Ollama

# Install and start Ollama
ollama serve

# Pull the model (in a new terminal)
ollama pull qwen:1.8b

3. Run the Server

python -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8000

4. Open in Browser

http://localhost:8000/app/

5. Access from Phone (Same WiFi)

# Find your PC's IP
ipconfig    # Windows โ€” look for IPv4 under Wi-Fi adapter

# On your phone browser:
http://YOUR_PC_IP:8000/app/

๐ŸŽ™๏ธ How to Use

Voice Mode

  1. Tap the Voice button or click the orb to start a voice call
  2. Ask naturally: "Is idli healthy?", "Can I eat paneer?", "What about dosa?"
  3. Bite.ai speaks the answer and auto-listens for your next question
  4. Tap again to end the call

Text Mode

Type any food query in the text box:

  • is biryani healthy
  • can diabetics eat rice
  • tell me about samosa
  • gulab jamun (just the food name works too)

Barcode Scanner

  1. Tap Barcode โ†’ use camera or type the number
  2. Supports multiple cameras (switch via dropdown)
  3. Works with EAN-13, EAN-8, UPC-A, UPC-E, Code-128, Code-39

Profile Setup

  1. Tap the Profile icon (top right)
  2. Set your name, allergies, health conditions, and diet type
  3. All verdicts are personalized to your profile

๐Ÿ› ๏ธ Tech Stack

Layer Technology Purpose
Backend FastAPI + Uvicorn API server, async request handling
Analysis Rule-based engine Instant nutritional verdicts (95% accuracy)
SLM Ollama (qwen:1.8b) Natural language fallback / enhancement
Food Data INDB Excel (1014 foods) Indian nutritional database with fuzzy matching
Barcode Open Food Facts API Global product database (2M+ products)
Frontend Vanilla HTML/CSS/JS No framework dependencies
3D Orb Three.js Interactive state visualization
Voice Web Speech API Browser-native STT + TTS
Fine-tuning Oumi + QLoRA Model training on Google Colab

๐Ÿ“Š Supported Food Queries

Query Type Examples Coverage
Indian foods idli, dosa, biryani, paneer, samosa, gulab jamun 1014 foods from INDB
Barcode products KitKat, Coca-Cola, Maggi, any packaged product 2M+ via Open Food Facts
Natural language "is X healthy?", "can I eat X?", "X for diabetics?" Flexible pattern matching
Greetings "hi", "hello", "thanks", "bye" Template responses

๐Ÿงช Fine-Tuning (Optional)

The system works out-of-the-box with the rule-based engine. For custom SLM training:

  1. Generate dataset: python scripts/generate_dataset_fin.py
  2. Train on Colab: Upload notebooks/colab_train.py to Google Colab
  3. Base model: Qwen2.5-0.5B-Instruct with QLoRA (4-bit)
  4. Framework: Oumi for training orchestration
  5. Export: GGUF quantization for Ollama deployment

See docs/07_finetuning_and_inference.md for the full training guide.


๐Ÿ“š Documentation

Document Description
01 โ€” Architecture System architecture, layer definitions, data flow
02 โ€” Intent Classification Rules layer, keyword router, latency strategy
03 โ€” Barcode Flow OFF API client, cache, follow-up queries
04 โ€” Non-Barcode Flow Food resolver, fuzzy matching, INDB lookup
05 โ€” Unified Schema & Agent Pydantic models, SLM prompt design, output parsing
06 โ€” Dataset Design Training data structure, augmentation strategies
07 โ€” Fine-Tuning & Inference QLoRA config, training script, inference pipeline
08 โ€” Conversation & Optimization Session management, context handling
09 โ€” Backend & Error Handling Failure modes, fallbacks, graceful degradation

๐Ÿ”ง Configuration

Environment Variables (Optional)

Variable Default Description
OLLAMA_URL http://localhost:11434 Ollama API endpoint
SLM_MODEL qwen:1.8b Ollama model for response generation
PORT 8000 Server port
HOST 0.0.0.0 Server bind address

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License โ€” see the LICENSE file for details.


Bite.ai โ€” Powered by Oumi
Built with โค๏ธ for healthier food choices

About

An AI-powered voice food assistant that provides instant nutritional verdicts through natural conversation and barcode scanning. Built with FastAPI, Ollama, and a hybrid rule-based + SLM pipeline for personalized food recommendations. (website only for frontend showcase)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages