Skip to content

ashish0553/ai-chatbot-rag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chukde RAG Chatbot Setup Guide

Prerequisites

  • Docker and Docker Compose
  • PHP 8.1+ with Composer
  • OpenAI API key

Quick Setup

  1. Create environment file:

    cp .env.example .env
    # Or run: bash setup-env.sh
  2. Update your OpenAI API key in .env:

    OPENAI_API_KEY=your-actual-openai-api-key
    
  3. Start services:

    docker compose up -d
  4. Install dependencies and setup Laravel:

    composer install
    php artisan key:generate
  5. Run migrations and seed data:

    php artisan migrate
    php artisan db:seed --class=DemoProductSeeder
  6. Index products in Qdrant:

    php artisan rag:reindex
  7. Start the application:

    php artisan serve

Testing the API

Test with exact SKU match:

curl -X POST http://127.0.0.1:8000/api/chat \
  -H 'Content-Type: application/json' \
  -d '{"q":"KRC-200"}'

Test with semantic search:

curl -X POST http://127.0.0.1:8000/api/chat \
  -H 'Content-Type: application/json' \
  -d '{"q":"Kashmiri Red Chilli 200g price"}'

Expected Response

Success response:

{
  "reply": "Here are the closest matches:",
  "products": [
    {
      "id": 1,
      "sku": "KRC-200",
      "name": "Kashmiri Red Chilli 200g",
      "brand": "Chukde",
      "price": 220.00,
      "offer_price": 199.00,
      "currency": "INR",
      "price_updated_at": "2025-01-21 12:01:33",
      "url": "https://chukde.com/product/kashmiri-red-chilli-200g"
    }
  ]
}

Not found response:

{
  "reply": "I couldn't find that product on chukde.com right now."
}

Architecture

  • MySQL: Stores product data and live prices
  • Qdrant: Vector database for semantic search
  • OpenAI: Embeddings API for text vectorization
  • Laravel: API framework with auto-indexing via model events

Auto-Indexing

Products are automatically indexed when:

  • Product is created/updated (UpsertProductVector job)
  • Product is deleted (DeleteProductVector job)

In development, jobs run synchronously (QUEUE_CONNECTION=sync). In production, use queue workers with QUEUE_CONNECTION=database or redis.

Tuning

  • Adjust score_threshold in ChatController (default: 0.75)
  • Higher threshold = more strict matching
  • Lower threshold = more lenient matching

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages