Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cloudflare RAG

Minimal RAG application on Cloudflare: Worker (TypeScript) + Workers AI (LLM) + D1 (documents) + KV (conversation memory) + React frontend.

Assignment mapping

  • LLM: Workers AI (@cf/meta/llama-3.1-8b-instruct)
  • Workflow/coordination: Cloudflare Worker (worker/src/rag-worker.ts)
  • User input: React chat UI (frontend/src)
  • Memory/state: KV (CONVERSATIONS) for conversation history

Live demo

Data

This app returns sources when matching content exists in D1. If you fork this repo, load your documents into D1 using the scripts in migrations/.

Minimal commands

# Insert a single test document (production D1)
wrangler d1 execute DB --command "INSERT INTO documents (id, content, source, metadata) VALUES ('test1','Reinforcement learning is a type of machine learning where an agent learns by interacting with an environment and receiving rewards.','test.md','{\"page\":1}');"

# Verify document count
wrangler d1 execute DB --command "SELECT COUNT(*) AS total FROM documents;"

Structure

cloudflare-rag/
├── worker/            # Cloudflare Worker API
│   ├── src/           # RAG pipeline
│   └── wrangler.toml  # Bindings (AI, D1, KV, Vectorize)
├── frontend/          # React chat UI
└── migrations/        # Import scripts

Repository requirements

  • Repository name must start with cf_ai_
  • Include PROMPTS.md at repo root with prompts used
  • Include this README with clear run instructions

About

A small web app that lets you ask questions over course notes. It includes: a backend on Cloudflare Workers that searches stored documents and returns answers with citations; a React frontend for a simple chat interface; D1 for document storage and KV for conversation history. Local development and deployment are supported with Wrangler and Pages.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages