Skip to content

thomas-desmond/are-you-ai-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The front page of the Are You AI? Demo Application

Disclaimer: All code and information provided in this repository is made available on an "as-is" basis with the express understanding that Cloudflare has no obligation to monitor, control, maintain or otherwise update the materials. This demo is intended for demonstration purposes only and should not be used for production workloads. Your use of the demo is at your own discretion and risk. Cloudflare makes no claims or promises about the quality, accuracy, or reliability of the demo, its safety or security, or content generated by the demo (if any). Cloudflare is not liable to you for any loss or damage that might arise from your use of the demo.

Deployment Guide

This application consists of two main components:

  1. A Next.js frontend deployed on Cloudflare Workers
  2. A Hono backend deployed on Cloudflare Workers

Prerequisites

Backend Deployment

Deploy to Cloudflare

  1. Click the "Deploy to Cloudflare" button above to deploy the /api directory to your Cloudflare account
  2. On the configuration page:
    • You can use default names or customize them for your application
    • For Vectorize settings:
      • Dimensions: 768
      • Metric: cosine
    • ⚠️ Important: Names cannot contain underscores (_)
  3. Save the URL of your deployed API for later use

Backend Setup

1. Create AI Gateway

Create an AI Gateway named are-you-ai-demo in your Cloudflare account:

2. Initialize Database

  1. Clone this repository to your local machine
  2. Create the database tables using the schema file, run this command in the root of the repository:
    npx wrangler d1 execute <your-db-name> --remote --file=./api/db-schema.sql
    Replace <your-db-name> with your D1 database name

3. Populate KV and Vectorize

Run these setup endpoints in order, it will look like nothing is happening but these setup scripts can take a few minutes to complete:

  1. Setup Images:

    • Visit: <your-api-url>/setupImages
    • Example: https://are-you-ai-api-test.thomas-development.workers.dev/setupImages
    • Wait until you see "Image Setup Complete"
  2. Setup Vectorize:

    • Visit: <your-api-url>/setupVectorize
    • Example: https://are-you-ai-api-test.thomas-development.workers.dev/setupVectorize
    • Wait until you see "Vectorize Setup Complete"

Frontend Deployment

Deploy to Cloudflare

  1. Deploy using the "Deploy to Cloudflare" button with default settings
  2. After deployment:
    • Go to the worker settings
    • Edit environment variable:
      • Name: API_ENDPOINT
      • Value: Your deployed API URL - no trailing / at the end
      • Example: https://are-you-ai-api-test.thomas-development.workers.dev

About

The Are You AI? Demo powered by Cloudflare

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published