AI Character Generator
Tags: cloudflarechallenge, devchallenge, ai, node
Published: 2024-04-10 05:45:49

*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

I've build a RPG character AI generator. It generates a name, back story, description of powers and traits plus the image of the character that is consistent with the description.

The only input necessary is the the class of the character or its species.



## Demo

Demo: [RPG Character Generator](https://www.nickname-generator.net/blog/fantasy-character-names/)


[![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vdwham273e7cj07jz9co.jpg)](https://www.nickname-generator.net/blog/fantasy-character-names/)

<!-- Share a link to your deployed solution on Workers or Pages, and add a screenshot or video embed of your app here. -->

## My Code

<!-- Show us the code! Share a public link to your repo and be sure to include a README file with installation instructions. We also encourage you to add a license for your code.  --> 

You can check out the code here: {%embed https://github.com/codingdudecom/ai-character-generator/ %}

## Journey

<!-- Tell us about your process, the task types and models you used, what you learned, anything you are particularly proud of, what you hope to do next, etc. -->

The app is pretty straight forwards and generates the result in JSON format, so it's very easy to integrate it in any kind of app, website or event game.

Making the [AI RPG Character Creator](https://www.nickname-generator.net/blog/fantasy-character-names/) widget I combined web development, AI integration, and Cloudflare Workers for seamless serverless computing. The primary objective was to design an intuitive interface where users could generate unique RPG characters complete with names, backstories, power details, and visual representations.

One of the standout features of the widget is its ability to generate a cohesive character profile with a name, backstory, powers, and image in real-time. Achieving this level of dynamic content creation using AI was a great experience for me.

Leveraging Cloudflare Workers allows the widget to handle a large number of concurrent requests without compromising on overall website performance.

I also learned that using the Dreamshaper 8 LCM model for image generation, while good enough, it did not present high adherence to the prompt/description of the RPG character. Therefore, I've had to switch to SDXL Lightning that takes into account much more of the details in the character description, provides a higher resolution results (1024px rather than 512px) and has a much more detailed and vibrant style.

**Potential further development**

**Enhanced Personalization:** I aim to further refine the UI to provide more personalized and diverse character creations based on user preferences and inputs. Perhaps using more diverse [AI character generator](https://www.mockofun.com/ai-image-generator-from-text/#:~:text=AI%20Character%20Generator-,AI%20Fantasy%20Portrait%20Generator,-You%20can%20now) prompts would allow creating even more visual appealing characters.

**Community Integration:** Introducing features that allow users to share and showcase their generated characters within a community setting is on the horizon. This will foster engagement and creativity among users.

**Multi-modal Interactions:** Integrating voice and visual inputs to allow users to interact with the widget in more natural and immersive ways is another exciting avenue I plan to explore.

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

<!-- Let us know if your project utilized multiple models per task and/or if your project used three or more task types. If so, you may qualify for our additional prize categories! If not, please remove this section. -->

I've decided to use two models: a llm and a text to image model. I believe that orchestration of AI inference for different models is a very powerful tool. In my opinion this way of working with AI models is far more flexible and more resource efficient than using [multimodal AI models](https://huggingface.co/models?other=multimodal).

At its core it is using 2 Cloudflare Workers AI models:

1. **LLM** - The _[zephyr-7b-beta-awq](https://developers.cloudflare.com/workers-ai/models/zephyr-7b-beta-awq/)_ is a good choice as lightweight and fast text generation model. I use it for creating the textual information for the RPG character.
 
2. **Image Generation** - The _[dreamshaper-8-lcm](https://developers.cloudflare.com/workers-ai/models/dreamshaper-8-lcm/)_ or _[stable-diffusion-xl-lightning](https://developers.cloudflare.com/workers-ai/models/stable-diffusion-xl-lightning/)_ are both good choices as lightweight and fast text generation models. They are text to image generators that are fast and appropriate for generating images (especially in the digital painting style). They are both a variations on the [Stable Diffusion](https://stability.ai/stable-image) model, and LCM (Latent Consistency Model) is an optimization of the model which renders quality images with impressive speed. While the lightning version is also an accelerated model version of the SDXL mode. You can try with the other [text to image models](https://developers.cloudflare.com/workers-ai/models/) just by replacing the `txt2img_model` variable in the code.

<!-- Team Submissions: Please pick one member to publish the submission and credit teammates by listing their DEV usernames directly in the body of the post. -->

<!-- Don't forget to add a cover image or an additional tag to this post (if you want). -->

<!-- Thanks for participating! -->