Skip to content
site logo mobile

ChatGPT + Python Chaining: One-Minute Hack Saves 10 Hours of Work!

Table of Contents

You are using ChatGPT the Wrong way or at least missing The Real Power of ChatGPT when combined with Chaining.

I wish every ChatGPT user read and try what is covered in this post.

chatgpt python chaining post

What is a ChatGPT Chain?

I think the best way to understand this concept is by showing a practical example.

Let’s assume that you are a YouTuber! and you have the video production workflow as follows:

Topic -> Title Ideas -> Thumbnail Ideas -> Script -> Record -> Edit -> Publish -> Promote.

πŸ’‘ By the way, I am a YouTuber, and here is my Ad-Free Channel if you wanna take a look. I share videos to help you 10X your marketing and online business with the Power of AI, ChatGPT,  Automation, and Python.

Anyway, this YouTube workflow usually takes an average of 10–30 hours, depending on the channel. For me, it takes around ~10 hours.

Let’s forget about recording and editing tasks for now, as they are out of scope in our case here; the other tasks will take like 3-5 hours.

So, in short, we want to cut down the time to 1 hour or less with the help of ChatGPT, and here are the main tasks that we have in our workflow:

Topic > Title Ideas > Thumbnail Ideas > Script > Promote.

You may tell me with some advanced ChatGPT prompts, chat with ChatGPT, and other YouTube AI tools Like PromoterKit. We can save time doing all this!

Yeah, maybe you are right! But it is not the best approach. We want something more powerful and stable!

And Remember that we are talking about a specific scenario here (the YouTube workflow) with 4–5 tasks.

We may have 20, 50, or even 100 Tasks in other workflows and scenarios! I will show you another example later in this post.

So I don’t think you want to go to ChatGPT every time and Start Chatting and asking for 50 or 100 tasks. Memorize the same prompts; maybe ChatGPT is down sometimes. It will probably take more time than the manual process! 🧐

So the idea is to create what we call an β€œAutomated-GPT-Chaining” Python Script.

Did you hear about Langchain or AutoGPT? It is something similar but way simpler and targeted to a specific scenario to achieve the best results.

If you didn’t hear about it, no worries. We are not using them here anyway πŸ™‚

πŸ’‘I am building a new GPT Library (Called OneShotGPT) I am planning to make it super powerful and super easy to use.Get notified When it is live by joining my newsletter here.

Running The Script 

Let me show you the power of this simple chaining technique in this 28 seconds demo video:

Cool Ha!

The Power of this script

So What is behind this script?

There are 4 main aspects of this project:

1- Advanced Prompts

If you open the file, you will find a list of prompts used. Feel free to customize and test if you want. These are the prompts used in our case to help generate ideas, script, and other stuff.

prompts chatgpt youtube.png

And these prompts must be customized based on your workflow (we will have an example later in this post)

2- Automation:

You don’t need to go every time and ask ChatGPT for each task manually. Everything is automated in 1 click!

Since this Python script runs automatically, you will not worry about memorizing prompts, opening ChatGPT every time, and chatting with it. All this will be automated, and you will get the results in less than 30 seconds.

3- Chaining:

Here is the core part. If you check the main script file, you will see that we are chaining the outputs. For example, the output of the first task (title ideas) is the input of the second (thumbnail ideas).

And the output of the third task (script) is the input of the fourth task (creating a Twitter thread). And so on.

This idea is very important as we are automatically feeding the results and building on top of it!

Take a look at the code

4- Simplicity:

This script is not written in the best way in terms of best practices. I made it like this to keep it simple for beginners. So anyone can edit and customize based on their specific workflow. 

Setup The Script

It is very easy to set up and run this script. All you need to do is. Download the script files. Install python. Install required modules. And run!

1- Get The Script

Click here to download the project files. Or check the source on GitHub here.

2- Install Python

Go to Download Python | and download the setup file. Run it and make sure to tick the β€œAdd Python to Path” checkbox.

3- Install the required modules.

Just open any terminal like Powershell or terminal inside visual studio code, and run the following command:

pip install openai

4- Set OpenAI API Key

Open the [] File, and paste the OpenAI key from your account.

python openai api key

5- Run the script file

In the downloaded project folder, you will find a batch file called “run-me.bat.” Double-click to see the magic.

python chatgpt script.png

Customize The Script.

In the prototype discussed above, we went through the Youtube production workflow.

What if you want to customize it for something else? Add more tasks? 

Let’s see a simple example of how to do that.

Let’s say you are a blogger, and you have this workflow:

Topic -> SEO Optimized Titles -> Writing The Blog -> Convert Into Twitter Thread

First, you will need to change the prompts; for example, a prompt that generates SEO optimizer Titles is:

I want you to act as a professional blog title 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 5 to 7 titles maximum. My blog post is about [Topic]

I use this prompt currently in my Free AI Title Generator tool on PromoterKit.

And then change the main script file to use these prompts instead.

chatgpt prompts.png

You may be thinking now. I need to learn Python, prompt engineering, and some other tech skills!

Why not! Come on; we are in 2023. Wake up!

And the good news is: I am here to help πŸ™‚

Check my free courses on my YouTube Channel (No Disturbing Ads, No Signups). Just click and learn. You can thank me by sharing this post and helping others πŸ™‚ And don’t forget to read the Quote Below ☟

Today’s Quote:

Invest in your self. it is the best investment you will ever do!

If you have any questions, I am here to help, waiting for you in the comments πŸ™‚

Earn Points for Every Share!

28 thoughts on “ChatGPT + Python Chaining: One-Minute Hack Saves 10 Hours of Work!”

  1. hey I’m having this problem

    openai.error.RateLimitError: You exceeded your current quota, please check your plan and billing details.

    its showing rate limit but its working just fine in there website!!
    should I change the selected model?? its gpt-3.5-turbo by default.. is there any basic model or something??

      1. Sir , first of all i want to give you a very big thanks and respect your work. Sir can I ask your motivation of doing all these amazing stuff at free of cost .

  2. Hi Hasan,
    I’m brand new to Python and Visual Studio but when I run the .bat file I pick up the error shown here:
    I’m assuming the piece I have circled has been created because I am still on the free version of ChatGPT. Would you agree?
    Are all the other comments relative to my free version of ChatGPT or can you see anything else I may have done wrong?
    I will be purchasing ChatGPT soon enough.
    Loving your stuff.

  3. Hi Hasan, I’m so thankful for your teaching. I have a question, I can’t seem to get gpt-4 working on this code. I have a paid subscription and I can use 4 in chat and Playground.

    Please advise.

    import openai

    openai.api_key = “sk-;kj;kvjz;vjz;LBJ;zljv;lK:ZLvkx…….”
    selected_model = “gpt-4”
    temprature = 1.0

Leave a Reply

Your email address will not be published. Required fields are marked *