Skip to content

dkumar247/cf_ai_supportwise

Repository files navigation

SupportWise — AI-Powered Customer Support Knowledge Base

Built entirely on Cloudflare's platform: Workers AI, Vectorize, Durable Objects, and Pages.

SupportWise lets teams upload their support documentation (FAQs, guides, product docs) and instantly query them using natural language. The AI finds the most relevant sections and generates accurate answers with source citations, reducing ticket resolution time.

Platform Language LLM


Architecture

┌─────────────────────────────────────────────────────┐
│                   User (Browser)                     │
│        Upload Docs  ←→  Ask Questions               │
└──────────────┬──────────────────┬────────────────────┘
               │                  │
         POST /api/upload    POST /api/ask
               │                  │
┌──────────────▼──────────────────▼────────────────────┐
│              Cloudflare Worker (index.ts)             │
│         Routing · Orchestration · CORS               │
└──────┬──────────┬───────────────┬────────────────────┘
       │          │               │
  ┌────▼───┐ ┌───▼────────┐ ┌────▼──────────────┐
  │Workers │ │ Vectorize   │ │ Durable Objects   │
  │  AI    │ │ (Embeddings │ │ (Chat Session     │
  │        │ │  Storage)   │ │  Memory)          │
  │- Embed │ │             │ │                   │
  │  (BGE) │ │- Store      │ │- Store messages   │
  │- LLM   │ │- Query      │ │- Retrieve history │
  │(Llama) │ │- Similarity │ │                   │
  └────────┘ └─────────────┘ └───────────────────┘

Components Mapping

Requirement Cloudflare Product Implementation
LLM Workers AI Llama 3.3 70B for answers, BGE-base for embeddings
Workflow/Coordination Workers Orchestrates: chunk → embed → store → retrieve → generate
User Input (Chat) Pages + Workers API Chat UI with document upload (PDF/TXT/MD)
Memory/State Vectorize + Durable Objects Vector embeddings + per-session chat history

Features

  • Document Upload — Drag-and-drop PDF, TXT, or Markdown files
  • Intelligent Chunking — Documents are split into overlapping chunks for better retrieval
  • Semantic Search — Questions are embedded and matched against document chunks via cosine similarity
  • AI-Generated Answers — Llama 3.3 generates answers grounded in retrieved context
  • Source Citations — Every answer shows which documents and sections it drew from, with confidence scores
  • Session Memory — Chat history persists per session via Durable Objects

Prerequisites

Setup & Running Locally

1. Clone the repository

git clone https://github.com/YOUR_USERNAME/cf_ai_supportwise.git
cd cf_ai_supportwise

2. Install dependencies

npm install

3. Authenticate with Cloudflare

npx wrangler login

4. Create the Vectorize index

npm run create-index

This creates a Vectorize index named support-docs-index with 768 dimensions (matching BGE-base embeddings) and cosine similarity metric.

5. Run locally in dev mode

npm run dev

Open http://localhost:8787 in your browser.

6. Try it out

  1. Upload a support document (try a FAQ or product guide as a .txt or .pdf)
  2. Wait for processing confirmation
  3. Ask a question related to the document content
  4. View the AI-generated answer with source citations

Deploy to Production

npm run deploy

Your app will be live at https://cf-ai-supportwise.<your-subdomain>.workers.dev.

Live Demo: https://cf-ai-supportwise.dkumar247.workers.dev


Project Structure

cf_ai_supportwise/
├── src/
│   ├── index.ts          # Main Worker: routes, Durable Object, orchestration
│   ├── embeddings.ts     # Document chunking, embedding, Vectorize storage
│   ├── rag.ts            # RAG pipeline: retrieve context → generate answer
│   └── types.ts          # TypeScript interfaces
├── frontend/
│   └── index.html        # Chat UI (Cloudflare-branded)
├── wrangler.toml          # Cloudflare configuration
├── package.json
├── tsconfig.json
├── README.md
└── PROMPTS.md

Tech Stack

  • Runtime: Cloudflare Workers
  • LLM: @cf/meta/llama-3.3-70b-instruct-fp8-fast via Workers AI
  • Embeddings: @cf/baai/bge-base-en-v1.5 via Workers AI
  • Vector DB: Cloudflare Vectorize (768-dim, cosine similarity)
  • State: Durable Objects (session chat history)
  • Frontend: Vanilla HTML/CSS/JS served via Workers Sites
  • Language: TypeScript

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors