Skip to main content

Command Palette

Search for a command to run...

I Added One Feature to a Tutorial Project. It Broke in 3 Ways.

How a Single Feature Update Brought Three Bugs and Enhanced My Development Skills

Updated
4 min read
I Added One Feature to a Tutorial Project. It Broke in 3 Ways.
S

Aspiring Generative AI and Agentic AI Developer with entry-level proficiency in Generative AI. My ambition is to help innovative companies build and deploy generative AI applications by using my skills in Python, LangChain, and agentic frameworks. Driven to apply the knowledge gained during my academic journey. Do you relate to my story, or want to know more about my background? I'd love to connect with you on LinkedIn! You can also reach me at 🔗linkedin.com/in/saiteja-puttoju 📧 saiteja.puttoju.ai@gmail.com

Hi everyone,

I'm new to tech and just built my first AI project. I want to share my story about it.

I started by following a YouTube tutorial. It showed me how to build an "AI Story Generator" using Python, Streamlit, and the Google Gemini API. The app was simple: you give it images, and it writes a story.

But I wanted to add one more thing: an "Additional Instructions" text box.

I wanted users to be able to type extra commands, like "Make the story very short", "Make it sound sad" or “Generate the story in another language”.

It seemed like a simple feature. But it broke my app in three new ways.

Here’s what my app looks like now. First, the clean starting screen:

And here is the final app after it works. You can see my custom instruction and the result!

You Can Try the App!

I hosted this project on Streamlit Community Cloud. I would be happy if you tried it.

➡️ Try the Live App: https://ai-story-generator-by-saiteja-puttoju.streamlit.app


My First Big Coding Problem

I was excited to add my new feature. But it did not work. Here are all the problems I found.

The Problem (What Went Wrong)

  1. The App Crashed: If I left my new text box empty and clicked "Generate," the app would show a big red error and crash.

  2. The "Spacebar" Bug: Then, I found another bug. If I just hit the spacebar a few times in the box, the app didn't crash, but it sent a messy, empty message to the AI.

  3. The AI Ignored Me: After I fixed those bugs, the AI still ignored my text! I typed "Make the story sad," and it wrote a happy one. It was very frustrating.

The Debugging (How I Fixed It)

I had to fix these problems one by one.

Fix 1: Stop the "Empty Box" Crash

My app crashed because it was trying to add "nothing" (a None value) to the prompt. Python did not like that.

I fixed this with a simple if check in my story_generator.py file. This just tells the code, "Only add the instructions if the user actually typed something."

# From story_generator.py
extra = extra_instructions.strip()
if extra_instructions:  # <-- This was my first fix!
    prompt += f"""
    ...
    TEXT: {extra}
    """

Fix 2: Stop the "Spacebar" Bug

The if check fixed the crash, but not the "spacebar" bug. A few spaces are not empty, so the if check passed.

I fixed this using the Python .strip() method. This is a great command that removes all blank spaces from the beginning and end of a text.

# From story_generator.py
extra = extra_instructions.strip() # <-- This was my second fix!
if extra_instructions:
    ...

Now, if a user only types spaces, .strip() turns it into an empty string, and my if check correctly stops it.

Fix 3: Forcing the AI to Listen

This was the biggest problem. My bugs were fixed, but the AI still did not care about my instructions.

I learned that my prompt was too weak. I had to learn "Prompt Engineering." I wrote a new, strong paragraph that tells the AI that my instructions are the most important rule.

This is the exact text I added to my prompt:

# From story_generator.py
# This text goes inside the `if` check

        The text below contains user‑specific requirements that must shape the final output. Treat them as authoritative whenever they differ from the general storytelling rules above. Where no conflict exists, combine both the base instructions and these additional directions to create a story that is both structured and personalized.
        TEXT: {extra}

That line, "Treat them as authoritative," was the magic key. It finally made the AI listen to me!

Watch the Live Demo

Here is a short, 1-minute video of me using the app.


Link: AI Story Generator Demo (Built with Python, Streamlit, & Gemini)

What I Learned

By adding just one feature, I learned about:

  • Safe coding (using if checks).

  • Cleaning user input (using .strip()).

  • Prompt engineering (using strong words like "authoritative").

It was a great first project for me. I am learning that fixing bugs is the best way to build new skills.

Thank you for reading my story!


I have a question for you: How do you handle user instructions in your own AI projects? I would love to read your ideas in the comments!