Building a fun facts generator with Pieces Copilot
When I first landed on the GenAI 101 Hub, what I really wanted was a real example, not just theory. I needed to see how someone actually used the command line and an AI assistant to build something from scratch. Here's what I built: a Fun Facts Generator App, powered by Pieces Copilot.
The problem
I wanted a quick way to demo prompt engineering in action, but with something playful and visual. Not just another CLI chatbot but a small web app I could build, customize, and host quickly.
As someone who’s leading webinars and working directly with students, I also needed something I could use to simplify GenAI concepts to their core. The goal was to create a hands-on example that feels approachable, interactive, and easy to follow, even for beginners.
The solution
I used Pieces Copilot to generate a single-page app that randomly shows fun facts about a user-defined topic. Here's how I tackled it:
Prompt Engineering
I started with a prompt like: “Generate 10 fun facts about cats.”
Copilot responded with a solid list, but some facts were clearly off – hallucinations. I refined the prompt until the content was realistic.
Debugging Hallucinations
One of the fun facts claimed cats can taste sweetness, which isn’t true. I updated the prompt to include “realistic and research-backed facts” to correct it.
Building the App
Copilot helped scaffold the HTML, CSS, and JS. I pasted all the snippets into a single index.html file using another prompt. Now the app generates a random fact each time you click the button.
Sharing it Live
I deployed it to GitHub Pages in seconds. No config files, no frameworks. Just code → push → publish.
🔗 View live demo
Code
# Fun Facts Generator App
## Overview
The **Fun Facts Generator App** is a fun, interactive web application that displays random "fun facts" about the User topic. Built using HTML, CSS, and JavaScript, this app allows users to apply the concepts of prompt engineering, context setting, and handling AI limitations (hallucinations) learned in GenAI 101.
## Purpose
This app was designed as a capstone project for the GenAI 101 workshop, allowing participants to:
- Understand prompt engineering and context setting.
- Recognize and address potential hallucinations in AI-generated content.
- Practice creating and customizing a simple, shareable web application using Pieces Copilot and basic web technologies.
## Key Features
- **Random Fun Fact Generation**: Displays a random, user-defined fun fact each time you click the button.
- **Facts Generated using GenAI**: Users can personalize the app by adding their own unique facts.
- **Easy Hosting on GitHub Pages**: With no additional setup, users can deploy their app online to share with others.
## Live Demo
You can view a sample app hosted on GitHub Pages here: [https:
## Step-by-Step Project Guide
This project is designed to be completed in 15 minutes. Each step incorporates key concepts from GenAI 101.
### Step 1: Define the Project Goal
- **Objective**: Create a fun, shareable app with "fun facts" about a topic you love, generated and customized using Pieces Copilot.
- **GenAI Concept**: Setting a clear project goal and prompt focus.
### Step 2: Generate Initial Fun Facts with Pieces Copilot
1. Open Pieces Copilot and input a prompt like, “Generate 10 fun facts about the Planet Earth.”
2. Experiment with variations, adjusting the prompt to include specific details and see how different prompt styles affect the generated text.
- **GenAI Concept**: Practice prompt engineering and adjusting context to create accurate outputs.
### Step 3: Identify and Correct Hallucinations
1. **Review the Generated Output**: Check for any unrealistic or fabricated details in the fun facts.
2. **Refine the Prompt**: Modify the prompt in Pieces Copilot if you notice hallucinations, ensuring the facts are realistic and accurate.
- **GenAI Concept**: Learn to identify hallucinations and handle inaccuracies in AI-generated content.
### Step 4: Build and Customize the App
1. Use Pieces Copilot to generate code snippets for HTML, CSS, and JavaScript to create a simple single-page app.
- **index.html**: Provides the basic HTML structure.
- **style.css**: Adds styling for a personalized look and feel.
- **script.js**: Contains JavaScript to handle random fact generation and user interactions.
2. Customize the fun facts by modifying the facts array in `script.js`.
3.
Example:
```javascript
const facts = [
"Cats are crepuscular, which means they are most active during dawn and dusk.",
"A cat's nose print is unique, just like a human fingerprint.",
"Cats can jump up to six times their height.",
"The average cat sleeps for about 12-16 hours a day.",
"Cats have a third eyelid, called a nictitating membrane, that helps protect their eyes.",
"A group of cats is called a clowder.",
"Cats can make over 100 different vocalizations, while dogs can only make about 10.",
"The oldest known cat lived to be 38 years old.",
"Cats use their whiskers to help them navigate and sense their environment.",
"Cats have a specialized 'purr box' in their throat that can vibrate at a variety of frequencies, and its believed this can promote healing."
];
```
4. Combine all these 3 code files into the `index.html` file by giving another prompt.
5. **GenAI Concept**: Document prompt adjustments and observe how context changes impact code accuracy.
### Step 5: Host on GitHub Pages and Share
1. Go to your GitHub repository and navigate to **Settings > Pages**.
2. Under **Source**, select the main branch and set the folder to `/root` and click `Save`.
3. Click **Save**. Your app will be live at a link like `https://yourusername.github.io/genai101/`.
4. Share the link to let others explore and enjoy your fun facts generator app.
- **GenAI Concept**: Share a practical AI-powered creation, reinforcing the importance of presentation and sharing.
### How to Use the App
1. Open the app in a browser using your GitHub Pages link.
2. Click the **Generate Another Fun Fact** button.
3. A new random fun fact will appear each time you click the button.
4. Share the link with friends or on social media to let others enjoy the small project you build with GenAI and Pieces!
### Troubleshooting Tips
- **Fun facts not displaying?**
- Check that `script` is correct in `index.html`.
- Ensure each fun fact in the facts array is enclosed in quotes and separated by commas.
- **Site not loading on GitHub Pages?**
- Confirm you’ve set the source to the main branch in GitHub Pages settings.
- Make sure your GitHub Pages URL is correctly formatted as `https://yourusername.github.io/genai101/`.
### License
This project is open-source and available under the MIT License. Feel free to use, modify, and distribute it as you like
Why this matters
Whether you're in a workshop, returning from PTO, or trying out a new AI dev tool, this kind of real, hands-on story shows how to go from prompt to product. It's not about hype. It’s about solving something small, quickly, and creatively with tools like Pieces Copilot, GitHub, and basic web tech.
If you're looking to build your first GenAI-powered app, this is a great way to start and understand where prompt tuning meets real development.
You can see how one of the students put this into action here:
👉 Croc Fun Facts – by Pratyush
This is a great example of how a beginner took the core concepts, prompt engineering, customization, and AI output handling, and applied them in a real, working project.
As a professional, I might approach things with a more optimized workflow, cleaner code, and deeper awareness of edge cases.
But what’s powerful here is the contrast: this project reflects what a student can actually accomplish when given the right tools and guidance. It shows how we can bridge the gap between instructional content and real implementation, without overwhelming them.