Skip to content

craigsdennis/chatflare

Repository files navigation

Chatflare

A web based chat interface built on Cloudflare Pages that allows for exploring Text Generation models on Cloudflare Workers AI. Design is built using tailwind.

This demo makes use of LocalStorage to maintain state. We have better solutions available (moar coming soon).

This is, like all of us, a Work in Progress.

Installation

npm install
# If this is your first time here
npx wrangler login

Develop

This uses the local Vite server for rapid development

npm run dev

Preview

This builds and runs in Wrangler your site locally, just as it will run on production

npm run preview

Deploy

This hosts your site on Cloudflare Pages

npm run deploy

Debug

npx wrangler pages deployment tail

Advanced

If you are on a Mac, you can generate the list of models in script.js by running the following commands:

# If this is your first time here. You won't regret it.
brew install jq
# Filter all Text Generation models into "ga" and "beta"
npx wrangler ai models --json | jq ' 
  reduce .[] as $item (
    {beta: [], ga: []};
    if ($item.task.name == "Text Generation") then
      if ($item.properties | any(.property_id == "beta" and .value == "true")) then
        .beta += [$item.name]
      else
        .ga += [$item.name]
      end
    else
      .
    end
  ) |
  .beta |= sort |
  .ga |= sort
'

TODOs

  • Add help area
  • Change settings to be "advanced" mode.
  • Get access in front of it
  • Use D1 for Session state