ChatCrafters - Chat with AI powered personas
Tags: cloudflarechallenge, devchallenge, ai, webdev
Published: 2024-04-12 23:10:28

---
title: ChatCrafters - Chat with AI powered personas
published: true 
tags: cloudflarechallenge, devchallenge, ai, webdev
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7t3gzoli2oy4j3nskycg.png
---

*This is a submission for the [Cloudflare AI Challenge](https://dev.to/devteam/join-us-for-the-cloudflare-ai-challenge-3000-in-prizes-5f99).*

## What I Built

[ChatCrafters](https://chatcrafters-c70.pages.dev) is a platform where you can create so-called "Personas". These are AI-powered characters who you can chat with, and they're all powered by a choice of six open models hosted by Cloudflare.

ChatCrafters also allows you to generate an image of the persona using just text with the help of the Stable Diffusion Lightning text-to-image generator. This allows you to better connect with your persona.

Personas can be used for many different purposes, such as fine-tuning the AI to focus only on one subset of professional work, and then asking it questions related to that work. It can also be used for general chatting and role-playing.

There is also a sharing system, where people can share their personas with others, and people can search for personas built by other people. This encourages community-building, and with features like the ability to Report Personas, this allows people do it safely too!

This app was built with [Svelte Kit](https://kit.svelte.dev), [Tailwind CSS](https://tailwindcss.com), and many other technologies. For a full rundown, please visit the [GitHub repository](https://github.com/arnu515/chatcrafters)

## Demo

The app is hosted live on <https://chatcrafters-c70.pages.dev>

Here are some screenshots:

![Messaging a persona](https://chatcrafters-c70.pages.dev/1.jpg)

![Exploring personas](https://chatcrafters-c70.pages.dev/2.jpg)

![Creating a persona](https://chatcrafters-c70.pages.dev/4.jpg)

## My Code

The code is hosted on [GitHub](https://github.com/arnu515/chatcrafters) with a permissive [MIT License](https://github.com/arnu515/chatcrafters/blob/master/LICENSE)

{% embed https://github.com/arnu515/chatcrafters %}

## Journey

There are quite a few applications similar to ChatCrafters out there, but most of them are built on top of closed models, which makes them just a black box in which you give your data and you get its output. Nobody except the company which made the application knows what happens to your data.

But this changes today. With the help of [Cloudflare's Workers AI](https://developers.cloudflare.com/workers-ai/), it has become much easier for anyone to build on top of open models, since the issues that were present before, such as the high upfront cost of GPUs, and/or the complexity of hosting such a model are handled by Cloudflare instead, and developers can just focus on building the app.

I decided to use [Svelte Kit](https://kit.svelte.dev) for this project, because of its [first class support](https://kit.svelte.dev/docs/adapter-cloudflare) for [Cloudflare Pages](https://developers.cloudflare.com/workers-ai/).

For the database, I decided to use [Cloudflare D1](https://developers.cloudflare.com/d1/), since it is fast, and bindings are already available without having to install/setup anything else.

Cloudflare makes calling the text generation models very easy, since every model has the same request format. Using multiple models becomes much easier, since the only part of the request that has to change is the Model's ID.

As of the time of writing, ChatCrafters has support for six different text generation LLMs, all thanks to Cloudflare.

ChatCrafters also supports image generation, with the help of Stable Diffusion XL Lightning, also hosted on Cloudflare. This allows you to give your Persona more character. 

**Multiple Models and/or Triple Task Types**

This application qualifies for both the Multiple Models, and the Triple Task Types categories.

This application uses eight different models!

One of them being [Stable Diffusion XL Lightning](https://developers.cloudflare.com/workers-ai/models/stable-diffusion-xl-lightning/), for generating Persona images.

It also uses [OpenAI Whisper](https://developers.cloudflare.com/workers-ai/models/whisper/) for speech recognition, so you can talk to your Personas!

The other six are Text Generation models. They are:

- [Llama2](https://developers.cloudflare.com/workers-ai/models/llama-2-7b-chat-int8/)
- [Mistral v0.2](https://developers.cloudflare.com/workers-ai/models/mistral-7b-instruct-v0.2/)
- [Neural Chat](https://developers.cloudflare.com/workers-ai/models/neural-chat-7b-v3-1-awq/)
- [OpenHermes](https://developers.cloudflare.com/workers-ai/models/openhermes-2.5-mistral-7b-awq/)
- [Llama2 13B](https://developers.cloudflare.com/workers-ai/models/llama-2-13b-chat-awq/)
- [TinyLlama](https://developers.cloudflare.com/workers-ai/models/tinyllama-1.1b-chat-v1.0/)

These models were handpicked by me after thorough testing on the [Cloudflare Workers AI LLM Playground](https://playground.ai.cloudflare.com/)

Hence, the three task types used are:

- Automatic Speech Recognition
- Text Generation
- Text-to-Image

I hope you enjoy using this application as much as I enjoyed building it! You can see it hosted live [here](https://chatcrafters-c70.pages.dev)