How To Create AI Tools in Minutes!

A simple script. You just need to copy, tweak a little bit, and then you can build almost any AI tool you want!

Hasan Aboul Hasan
6 min readJan 10, 2024
AI Generated

After you finish the post, you will be building your first AI tool in less than 2 minutes without writing any code!

You will just use my script, prompt, and some commands That I will share with you here.

source: LearnWithHasan.com

Here is what I will cover Today:

  • Understand the Basic Structure of AI Tools
  • The Main challenge in Building AI Tools
  • The Solution: Build The Tool Using my Custom Script
  • Build a User Interface in 2 Methods

Understand the Basic Structure of AI Tools

Take a look at this image:

So, like any tool, an AI tool consists mainly of the UI (User interface) and the backend process, which basically generates “Something with AI.

To make things simple, let’s go with a practical, real example. Let’s Build an “AI Blog Title Generator Tool

The Basic AI Tool Workflow is as follows:

User Input: The starting point of any AI tool is the user input. For instance, in our example, the blog title generator tool, a user inputs a topic, e.g., digital marketing.

Then, the user input “topic” is inserted into a prompt like this one:

I want you to act as a professional blog titles generator. 
Think of titles that are seo optimized and attention-grabbing at the same time,
and will encourage people to click and read the blog post.
They should also be creative and clever.
Try to come up with titles that are unexpected and surprising.
Do not use titles that are too generic,or titles that have been used too many times before. I want to generate 10 titles maximum.
My blog post is is about {topic}

IMPORTANT: The output should be json array of 10 titles without field names. just the titles! Make Sure the JSON is valid.

Example Output:
[
"Title 1",
"Title 2",
"Title 3",
"Title 4",
"Title 5",
"Title 6",
"Title 7",
"Title 8",
"Title 9",
"Title 10",
]

Then, this prompt will be sent to the OpenAI API or any other AI API, which will then generate relevant titles.

Finally, the generated response will go back to the user and be displayed in the UI.

But in order to build a UI based on that response, it must be in a structured JSON format.

The Main challenge in Building AI Tools

Ok, the idea seems simple and straightforward, but there is one Main challenge that faces us when we build AI tools. It is achieving consistent, structured responses from AI models.

Why Consistency Matters

  1. User Interface Integration: A consistent format in AI responses is crucial for seamless integration with user interfaces. Inconsistent responses can lead to unpredictable UI behavior, affecting user experience.
  2. Predictability in Output: Developers rely on predictability to ensure their tools function as intended. Varying response structures create a need for additional parsing and handling logic, increasing complexity.
  3. Scalability Issues: As tools evolve and more features are added, maintaining them becomes more challenging with inconsistent responses.

Causes of Inconsistency

  1. Varied Prompts and Responses: Different prompts can lead AI models to generate responses in various formats. For example, asking for ‘five blog titles’ might return a list in one instance and a paragraph in another.
  2. Model Behavior: AI models, especially those based on machine learning, can exhibit non-deterministic behavior. The same prompt might yield slightly different responses upon repeated requests.
  3. Complexity of Natural Language: Natural language is inherently complex and nuanced. AI models sometimes interpret the same prompt in different ways, leading to varied responses.

Example of Inconsistent Responses

In one instance, a request for blog titles about ‘digital marketing’ might return a straightforward list. In another, the model might provide a more descriptive response, including explanations or additional information.

Try it yourself on ChatGPT, ask it to generate 5 blog titles multiple times, and look at the response!

So, how do we solve this problem?

The Solution: Build The Tool Using My Custom Script!

To solve this problem, we can employ techniques like function chaining, function calling, example output prompts, and some others. You can learn more about these techniques and more in my Prompt Engineering Mastery Course.

But today, I want to make things way easier. I prepared a script for you; this script will handle this problem and help you get consistent results every time without worrying about the underlying code.

First, Get my script on GitHub here:

Get The Script

Open the Python script (app.py) in VSCode or any IDE you want. Just replace the fields and test!

Set the OpenAI API Key in the .env file here:

Just run the script with this command:

python app.py

You will see you will get consistent JSON every time you run the program.

Problem Solved ✅

It is time to build the UI.

Build The User Interface

Ok, let me share with you 2 simple methods to create a UI for your AI Tools.

Method 1: Using ChatGPT and Streamlit

What is Streamlit?

Streamlit is an open-source Python framework for rapidly creating web applications. It’s designed for developers looking to turn scripts into shareable web apps with minimal effort.

To make things simple for you and create the UI with Streamlit in seconds, I prepared a special Power Prompt that can transform almost any Python script into a Streamlit app!

The Prompt:

Act as an expert Python programmer specialized in building user-friendly UIs using Streamlit.
Create a Streamlit UI for the provided script. Make sure to comment all the code to enhance understanding, particularly for beginners. Choose the most suitable controls for the given script and aim for a professional, user-friendly interface.
The target audience is beginners who are looking to understand how to create user interfaces with Streamlit. The style of the response should be educational and thorough. Given the instructional nature, comments should be used extensively in the code to provide context and explanations.
Output:
Provide the optimized Streamlit UI code, segmented by comments explaining each part of the code for better understanding.
Input:
Provided script: {your input script}

Use ChatGPT and replace the input with our tool script. And see the Magic!

ChatGPT will create the full Streamlit code with you and explain every step.

I designed it to help beginners get started easily and understand what is going on.

So, in our project, create a new script, let’s name it “ui.py” and paste the generated code.

To run the Streamlit app, run the following command:

streamlit run ui.py

Wait for seconds, and you will see your AI app up and running in your browser.

💡Pro Tip: You can start building AI Tools with streamlit and sell as a freelance Gig or service. it is a new niche.. a New Opportunity!

The Second simple way to build UI is using WordPress.

You can see I have built multiple AI tools here on my site. You can check my Tools Page here.

To learn how to build AI tools with WordPress, check this post.

And if you want learn how I monetize my tools with the points system and how I Build a SaaS on WordPress, you can check my full course here.

Have Questions? See you on the forum.

--

--

Hasan Aboul Hasan
Hasan Aboul Hasan

Written by Hasan Aboul Hasan

Digital Entrepreneur with 9+ years' experience | Running 5 Startups | YouTuber | Helping you build digital businesses through tech & entrepreneurship.

Responses (18)