In this post, I will give you a simple script. You just need to copy and tweak a little bit, and then you can build almost any AI tool you want!
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.
![Create AI Tools fast for beginners](https://learnwithhasan.com/wp-content/uploads/2023/12/Copy-of-Copy-600-x-200-px.png)
Understand the Basic Structure of AI Tools
Take a look at this image:
![create ai tools fast](https://learnwithhasan.com/wp-content/uploads/2023/12/Copy-of-Copy-600-x-200-px-1.png)
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 user input. For instance, in our blog title generator tool, a user inputs a topic, such as digital marketing.
![build ai tools for beginners](https://learnwithhasan.com/wp-content/uploads/2023/12/Copy-of-Copy-600-x-200-px-2.png)
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.
Note that we are talking here about general AI tools and not complex tools that may have complex and advanced structure.
The Main challenge in Building AI Tools
Okay, the idea seems simple, but there is one main challenge when we build AI tools: achieving consistent, structured responses from AI models.
Why Consistency Matters
- 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.
- 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.
- Scalability Issues: As tools evolve and more features are added, maintaining them becomes more challenging with inconsistent responses.
Causes of Inconsistency
- 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.
- Model Behavior: AI models, especially those based on machine learning, can exhibit non-deterministic behavior. For example, the same prompt might yield slightly different responses upon repeated requests.
- 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!
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 in my Prompt Engineering Mastery Course.
But today, I want to make things much easier. I prepared a script for you which 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:
Open the Python script (app.py) in VSCode or any IDE you like and replace the fields and test!
![build ai tools pydantic](https://learnwithhasan.com/wp-content/uploads/2023/12/Screenshot-2023-12-07-133220.png)
Set the OpenAI API Key in the .env file here:
![](https://learnwithhasan.com/wp-content/uploads/2023/12/Screenshot-2023-12-07-133445-1024x407.png)
Just run the script with this command:
python app.py
You will see you will get consistent JSON every time you run the program.
![](https://learnwithhasan.com/wp-content/uploads/2023/12/Screenshot-2023-12-07-133623-1024x171.png)
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}
Replace the input with our tool script, see how 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.
![](https://learnwithhasan.com/wp-content/uploads/2023/12/Screenshot-2023-12-07-163558-1024x533.png)
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.
![](https://learnwithhasan.com/wp-content/uploads/2023/12/Screenshot-2023-12-07-163846-1024x720.png)
💡 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. If you go to my Tools Page, you will see multiple AI tools which I have built.
To learn how to build AI tools with WordPress, check this post.
And if you wanna 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.
hello sir can you guide me on How to use this tool in WordPress full guide step by step
I am preparing a full course
I can’t wait (p). Thank you Hasan
Sounds great
thank you
I couldn’t link .env file in helpers it shows error to me, Any solution please??
please join the forum, and submit your questions there
how to build AI tools with WordPress- can we use bard api instead openai api
yeah sure, you can use any api you want.
Hi Master Hasan
Could you teach, how to build a Youtube tool similar that you have…. I mean, display data about most viral videos (thumbnail, titles, etc)
I will try my best 🙂
Thanx sir for this. I have a blog on WordPress ca I add a AI tool on?
That is a wonderful tutorial .
I suggest you to create another tutorial on how to us streamlit to create ui using chatgpt step by step
Thanks, I will try my best
Hi, Thanks for very well guiding to everyone. I salute your efforts
Pingback: Get Consistent Structured JSON From Gemini with Python
Pingback: How to Build a Plagiarism Detector Using Python [Part 1] - LearnWithHasan
Pingback: Find Similar Research Paper Abstracts in 5 Minutes With AI and Python - LearnWithHasan