Create a Python GPT Chatbot - In Under 4 Minutes

Поделиться
HTML-код
  • Опубликовано: 31 май 2024
  • Today I'm going to be showing you guys how you can make a python chatbot using OpenAI and ChatGPT in JUST 5 MINUTES!
    💻 Get an API Key: platform.openai.com/account/a...
    💻 Master Blockchain and Web 3.0 development today by using BlockchainExpert: 🔗 algoexpert.io/blockchain (Use code "tim" for a discount!)
    💻 Accelerate your software engineering career with ProgrammingExpert: 🔗 programmingexpert.io/tim (Use code "tim" for a discount!)
    🎬 Timestamps⏱️
    00:00 | Installing OpenAI
    00:32 | Getting an API Key
    00:53 | Writing The Bot
    03:01 | Testing The Bot
    ◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️
    👕 Merchandise: 🔗 teespring.com/stores/tech-wit...
    📸 Instagram: 🔗 / tech_with_tim
    📱 Twitter: 🔗 / techwithtimm
    🔊 Discord: 🔗 / discord
    📝 LinkedIn: 🔗 / tim-ruscica-82631b179
    🌎 Website: 🔗 techwithtim.net
    📂 GitHub: 🔗 github.com/techwithtim
    One-Time Donations: 💲 www.paypal.com/donate?hosted_...
    Patreon: 💲 / techwithtim
    ◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️
    ⭐️ Tags ⭐️
    - Tech with Tim
    - Chatbot
    - Openai
    ⭐️ Hashtags ⭐️
    #chatbot #python #5minutetutorial

Комментарии • 189

  • @TechWithTim
    @TechWithTim  7 месяцев назад +12

    I just released an INSANE software development course, check it out here 👉coursecareers.com/a/techwithtim?course=software-dev-fundamentals

  • @GeobotPY
    @GeobotPY 7 месяцев назад +13

    Love this! Would love to see more in-depth vids about function calling, deployment and chatbot use-cases for businesses. Keep it up!

  • @ChannelMantle
    @ChannelMantle 6 месяцев назад +4

    As beginner who has been struggling with different methods of having a user exit a program or loop, and having used various ways of doing so, I really loved the idea of defining options in a list like that. It might be super obvious now that I have seen it, but what a great little snippet of code - I am definitly bringing it with me going forwards.

  • @AIDummy101
    @AIDummy101 7 месяцев назад +9

    Thanks for breaking it down in under 4 minutes. This tutorial is incredibly helpful!

  • @user-xk7de1jw8g
    @user-xk7de1jw8g 7 месяцев назад +10

    I didn't even imagine building a Chatbot, however simple it is, is so easy. Thanks Tim for opening up my mind.

    • @liamjohnsons
      @liamjohnsons 5 месяцев назад

      This isnt building one this is important one

  • @AndreiDante
    @AndreiDante 7 месяцев назад +3

    I've searched for stuff like this when I've discovered chatGPT and thinking that I can improve my virtual assistant.
    Now I can give my virtual assistant some new neurons to provide some information directly.
    Thanks a lot!!

  • @christianbjerregaard2549
    @christianbjerregaard2549 7 месяцев назад +119

    But this requires a paid plan. Probably worth mentioning.

    • @TechWithTim
      @TechWithTim  7 месяцев назад +25

      Yes, but it costs fractions of a cent!

    • @maxfarouk3407
      @maxfarouk3407 7 месяцев назад +33

      ​@TechWithTim still worth mentioning. Especially with your last video on openai. Not everyone has that immediate opptunity. It's not fair for your audience to follow your tutorials only to be met with a pay wall because they weren't informed. Sure its cheap, but it only takes two seconds of your time to save others a lot of time.

    • @TechWithTim
      @TechWithTim  7 месяцев назад +33

      You're right, an oversight by me, I appreciate the feedback and will be more careful in future videos! @@maxfarouk3407

    • @collinsmwaura3056
      @collinsmwaura3056 7 месяцев назад +16

      This is usually a nightmare for devs in 3rd world countries

    • @maxfarouk3407
      @maxfarouk3407 7 месяцев назад +3

      @@TechWithTim Sweet man, Its not a huge deal.

  • @Olurii
    @Olurii 7 месяцев назад +5

    This was awesome I would love to see some content about deploying the ai's on different platforms

  • @delsune
    @delsune 7 месяцев назад +3

    Hey Tim, I wanted to make a version of this where the response would be read out bye a custom tts voice using pytts. What websites do you recommend using for creating this custom tts voice (based on manual training)?

  • @krzysztofmydowski
    @krzysztofmydowski 7 месяцев назад +7

    Hello, I have a problem because I have the key but it shows me that I have exceeded my current amount of available resources on OpenAI and I haven't even used it. Is it possible to have this without providing a credit card?

  • @user-xn5ji6ni5m
    @user-xn5ji6ni5m 5 месяцев назад

    God bless you and your family Tim, you are a hero.

  • @user-fv3ce5xm3r
    @user-fv3ce5xm3r 3 месяца назад

    It helps me a lot! Thank you.

  • @strudelman1288
    @strudelman1288 4 месяца назад

    Thank you very much for this video. It will make my work much easier. I am making a script that will take your voice, convert it to text, run it through ChatGPT, and then throw it into Text To Speech.

  • @sojeyusuf149
    @sojeyusuf149 7 месяцев назад

    This is brilliant, good work...

  • @allfires4957
    @allfires4957 7 месяцев назад +5

    Yooo dude this is sick 🎉

  • @alejandroreyna5952
    @alejandroreyna5952 2 месяца назад

    Wow .. Excelent !!! . Thank you very much

  • @PrayDaily485
    @PrayDaily485 4 месяца назад

    This is great... Thanks man

  • @artistpw
    @artistpw 27 дней назад

    You make great content, thanks!

  • @mrpenk9720
    @mrpenk9720 6 месяцев назад

    hey Tim, knowing what you know about advancements in AI, would you still learn how to code if you wouldn't remember anything tomorrow, and had to start completely from the beginning again? i just need a yes or a no , I'd be so happy for your answer. thank you !

  • @Athielmon
    @Athielmon Месяц назад +3

    Very good tutorial. I been trying to make it work with different versions of code but everytime I get the same error:
    " You exceeded your current quota, please check your plan and billing details" I have tried several models and keep getting the same error

  • @michelangelomatteoda4814
    @michelangelomatteoda4814 16 дней назад

    Is the first software you use your terminal or another IDE? Thanks for clarifying

  • @HamedEmine
    @HamedEmine 7 месяцев назад +4

    Thanks Tim for making everything easier for us

  • @paulthomas1052
    @paulthomas1052 7 месяцев назад

    Hi Tim, really enjoy your videos but on a Mac with Python 3.12 getting 'openai' to install seems to be an issue. Any ideas ?

  • @BigIglooGaming
    @BigIglooGaming 5 месяцев назад

    I understand that there is a payment to be done in order to get the API key. Since my account was created maybe a year ago, my 3 months free ran out. So would I have to buy the $20 a month purchase, or is there another way to just buy the API keys itself so it works?

  • @JanKowalski-dm5vr
    @JanKowalski-dm5vr 5 месяцев назад +3

    So it's not a conversation, every time it's just a prompt and a response, because the chat doesn't remember previous posts. So I added a few lines of code to upgrade this:
    "
    import openai
    openai.api_key = "paste your key"
    def chat_with_gpt(chat_log):
    response = openai.ChatCompletion.create(model='gpt-3.5-turbo',
    messages=chat_log
    )
    return response.choices[0].message.content.strip()
    chat_log = []
    # Remembering more posts is more expensive
    n_remembered_post = 2
    if __name__ == "__main__":
    while True:
    user_input = input("You: ")
    if user_input.lower() in ['quit', "exit", "bye"]:
    break
    chat_log.append({'role': 'user', 'content': user_input})
    if len(chat_log) > n_remembered_post:
    del chat_log[:len(chat_log)-n_remembered_post]
    response = chat_with_gpt(chat_log)
    print("Chatbot:", response)
    chat_log.append({'role': "assistant", 'content': response})
    "

  • @GBroSM
    @GBroSM 3 месяца назад

    amazing video Tim, you always create the best and most useful python content online! Thank you so much! can you please make the same video but based on 2024. because now its not free, and you could be the first one to show us how to make this tech in 2024!!

  • @roadto8band246
    @roadto8band246 7 месяцев назад

    Can't wait to see more tutorials about AI!!!🎉🎉

  • @richardsifeanyi6766
    @richardsifeanyi6766 7 месяцев назад

    Thanks Tim.

  • @NOPOLO-km2pz
    @NOPOLO-km2pz 7 месяцев назад +3

    Hello, I'm facing an issue where I can't import the OpenAI library. I have Python installed correctly and it's up-to-date. I also have the API key, but I'm unable to install the OpenAI library. Does anyone have a solution?

  • @trxlly
    @trxlly 6 месяцев назад +1

    Thanks!

  • @Excellence-YT
    @Excellence-YT Месяц назад +1

    Can you please tell the openai version as it doesn't seem to be working for me on the latest version

  • @alexcroome2955
    @alexcroome2955 7 месяцев назад +3

    I was considering designing a skill system using chat gpt to create random skills based on character actions. You could have chat gpt respond with .json style skills, titles, etc based on player actions and achievements.

    • @TechWithTim
      @TechWithTim  7 месяцев назад +1

      Check out my recent choose your own adventure game using ai, it does a similar thing!

  • @BlazeTheCatMan
    @BlazeTheCatMan 7 месяцев назад

    can you run this offline like how dependent is is it when comes to the future like if open ai shuts down would mine that i made still work?

  • @Seshhh..
    @Seshhh.. 5 месяцев назад +2

    this is the error i am getting right now . What should i do ?
    You tried to access openai.Completion, but this is no longer supported in openai>=1.0.0

  • @armandoruggeri7798
    @armandoruggeri7798 5 месяцев назад +5

    Why I get an exceeded quota limit if I have got just errors? Moreover it seemd ChatCompletion doesn't exist and I should turn back to openai version o.28. How I sort it?

    • @BurgerSoda
      @BurgerSoda Месяц назад

      i have the same problem with the quota limit, did you fix it yet?

  • @massimilianoasara
    @massimilianoasara 5 дней назад

    Very well done. Is there any way to implement this with one of the customized "myGPT's"?

  • @GiuliaSironi-fo2df
    @GiuliaSironi-fo2df 17 дней назад

    Hi, i'm totally new to programming. How can i do this on google collab? Which platform should i use?

  • @SaEeDsImP
    @SaEeDsImP 7 месяцев назад +1

    عالي و آموزنده

  • @aguy3_3
    @aguy3_3 7 месяцев назад +2

    Can you do the same thing with C#? Js asking.

  • @daveys
    @daveys 7 месяцев назад

    While it’s pretty cool to be able to do this, it’s easy enough to have a browser open and do it via there. Where I think this is useful, is if you pass things to gpt to summarise or do stuff with. Still got to be careful with what you feed any of these AI’s, but still being able to interact in python is useful.

  • @NateYaquinto
    @NateYaquinto 7 месяцев назад +3

    Really appreciate this video! The only problem I ran into is that the chatbot doesn't remember the context of the conversation. Its like creating a new chat every time you input something

    • @bdcash
      @bdcash 7 месяцев назад +2

      You need to build up a list of responses in each direction and feed that to the openai api at each interation. But that would take more than five minutes....

  • @arthureffrontmusic
    @arthureffrontmusic Месяц назад

    Is there a way to give the api some rules so that the ai responds as if it were a predefined character ? Like a person with a specific name, age etc

  • @danibaiju
    @danibaiju 7 месяцев назад +3

    AttributeError: module 'openai' has no attribute 'ChatCompletion'

  • @ArthasDKR
    @ArthasDKR 7 месяцев назад +1

    My openai account is more than 3 months old so when I create a new API key, it doesn't working saying quota exceeded :(
    I dont wanna create a new account ;-;

  • @jancovanderwesthuizen8070
    @jancovanderwesthuizen8070 Месяц назад +1

    Can you connect this to a custom GPT instead of just 3.5 Turbo?

  • @Spedclover
    @Spedclover 7 месяцев назад +1

    Can u explain please how to do the same thing but with the Google Bard

  • @willtaylor8260
    @willtaylor8260 18 дней назад

    Great video! I would love to see how to make this work on iOS or Android.

  • @hanshusyed-lq5ng
    @hanshusyed-lq5ng 29 дней назад

    Hi I got an error like this -"import openai" could not be resolved pylance(reportmissingimports)[ln1,col8]

  • @sv2109
    @sv2109 7 месяцев назад +1

    Correct me if I'm wrong, but this code probably doesn't use history, so every new request is a new request for GPT and GPT doesn't remember what you asked before. You need to save all history and send it with every request. Isn't it?
    I didn't use this library with python, I worked with GPT in PHP.

  • @vazquezsebastian9764
    @vazquezsebastian9764 6 месяцев назад

    Simply explayned and superbe quality content, would love to see more

  • @oliversimmons988
    @oliversimmons988 Месяц назад

    good video: super new to this, how did he do def in italics?

  • @EnglishRain
    @EnglishRain 7 месяцев назад

    Look forward to more tiny videos

  • @zakariaa6171
    @zakariaa6171 7 месяцев назад

    And thanks for your good content

  • @rubenromeroruiz
    @rubenromeroruiz 7 месяцев назад

    Great!!

  • @ikshwakvarma3610
    @ikshwakvarma3610 27 дней назад

    Hey, I have been following you for a long time. I have tried this but it didn't work may be it is demanding subscription ryt now.
    Anyways my question is.. Do you have any alternate source other than openai, if Yes would you make a video on that, That would do a great help

  • @superpayaseria
    @superpayaseria Месяц назад +2

    As of April 12th - 2024' it say's these packages are no longer available.

  • @kushalkale2315
    @kushalkale2315 2 месяца назад

    I want to create chatbot for handling support tickets. I have thousands of support tickets from the past and i want the chatbot to use that data to answer new customer queries. How do i do that?

  • @MDArman-fk8iy
    @MDArman-fk8iy 3 месяца назад

    Dear brother, I have a question, can I use these codes on the WordPress site?

  • @williamhiciano394
    @williamhiciano394 2 дня назад

    is there a way that i can use a custom model created with gpt creator and use it in this code?

  • @amitpatel9670
    @amitpatel9670 7 месяцев назад +1

    Could you please make a video on using llama2 as well?

  • @masked00000
    @masked00000 7 месяцев назад

    How do you edit your videos?

  • @Player_606
    @Player_606 Месяц назад +1

    How do you got that python? My python is different and i cant do that.

  • @user-mc6mc9ww4s
    @user-mc6mc9ww4s Месяц назад

    how to run code on macos terminal ,
    its showing command not found .

  • @humeidussenejocordasse791
    @humeidussenejocordasse791 7 месяцев назад

    Amazing

  • @muchainganga9563
    @muchainganga9563 7 месяцев назад

    How can we limit the " as an AI repetitive response?

  • @Mai_Tai_Meyers
    @Mai_Tai_Meyers 5 месяцев назад

    Does this still work for anyone? I'm trying to get it to work, but it says that I exceeded my current quota for API calls. Is this service only paid now?

  • @punwind7039
    @punwind7039 7 месяцев назад +1

    Thanks Tim! Can you make a video about pushing at chatbot like this to a unique website URL with Flask? (I have a domain with dreamhost and just can't seem to get it to work. Any tips would be greatly appreciated!)

    • @TechWithTim
      @TechWithTim  7 месяцев назад +1

      Not a bad idea! Thanks :)

  • @user-ut9nn6jl8f
    @user-ut9nn6jl8f 5 месяцев назад

    hello tim it is great project. can't imagine putting it in my resume.
    there is a little problem i am facing is there is some api error showing. I am doing exactly the same steps you are doing.
    can you please help to figure it out?

  • @rohitpandey9920
    @rohitpandey9920 6 месяцев назад

    On giving user input, I keep getting the rate limit error. Please help

  • @BotturasStudios
    @BotturasStudios 7 месяцев назад +3

    I'm getting the error: You exeeded your current quota, please check your plan and billing details.
    Do I need to pay for it to work?

    • @nicolanoventa5244
      @nicolanoventa5244 7 месяцев назад

      yes, for the API you have to pay. it's very low price based on how much you use it ($0.0015 / 1K tokens). for a quick calculation you can consider 1 word as approximately one token. if you stay under a few dollars they will not deduct anything from the card.

    • @user-js9rz5ue7w
      @user-js9rz5ue7w 7 месяцев назад

      Yes :(

  • @kirpalshergill
    @kirpalshergill 6 месяцев назад +1

    i wrote the same code but it keeps showing me the error

  • @mahrukhhafeez7398
    @mahrukhhafeez7398 2 месяца назад

    It is very simple to make it indeed. But it is not working for me. It is only giving me option to write by myself. "You : " is showing only and no response is generated by the chatbot.

  • @user-mu9en3tb8v
    @user-mu9en3tb8v 2 месяца назад

    cool video)

  • @LUKEMAC514
    @LUKEMAC514 7 месяцев назад +4

    “Create a Python GPT chatbot” is quite a inaccurate title. You are not creating a GPT chatbot, you are simply making api calls. A better title would be “How to use openai’s API”.

  • @eternalgamer496
    @eternalgamer496 7 месяцев назад +1

    I just added this to my discord bot and ran my first prompt, it says that I am rate limited cause it exceeds my quota limit.
    is the api paywalled or am I missing something?

    • @TechWithTim
      @TechWithTim  7 месяцев назад

      U can use it for free but u need to pay if you over the free usage - that was how it worked last time I used it

  • @user-ii5he7tl6r
    @user-ii5he7tl6r 7 месяцев назад

    is the free tokens over? or it is still there?

  • @samore11
    @samore11 7 месяцев назад

    Not sure I get how to use this. Prompt the chatbot in your code to get some data that you would use in your code later?

    • @foqsi_
      @foqsi_ 7 месяцев назад

      You could use it for whatever you'd like. The first thing that came to my mind, was a support bot. Customize the prompt to correlate with a particular company and prevent specific texts, then it could be used to help end users with whatever it's set up for. For instance, IT chat bot would troubleshoot a user's hardware/software issues via text before routing to a person. We see this often on websites if you start a chat. Personally, I could use this for my own website that would help users understand that the data my site uses only supports content from the US, or why even some of that content is missing. This way, they could just ask the bot instead of sending me messages/emails.
      Maybe create a desktop application for yourself, so you don't have to open up the webpage anytime you want to communicate with it. Implement voice, so you can do talk to text. Maybe add a button that generates a random fact from it. haha.
      You could do whatever you'd like! AI is a great tool. Utilize it. The rate it's been growing over the past year, any and every developer should probably be working with AI. Many companies, small and large have already started implementation.

  • @marie-pierneault1035
    @marie-pierneault1035 3 месяца назад

    Do I need to add token to my account to make it works or is model gpt-3.5-turbo gives you a amount of free token to use to practice? Thanks!

    • @marie-pierneault1035
      @marie-pierneault1035 3 месяца назад

      Nevermind, I made it work by putting the api_key in the client = OpenAi(). Thanks!

    • @naghulpranavkk
      @naghulpranavkk 2 месяца назад +1

      Could you elaborate on this please ​@@marie-pierneault1035

  • @cosmos3797
    @cosmos3797 4 месяца назад +9

    Now there's an update, it's not working anymore 😢.
    Can you please make a video based & working it work with the updates.

  • @jitjena5291
    @jitjena5291 4 месяца назад

    Can you make the chatgpt with files uploading also. That will require the gpt4 i guess.

  • @B-NANA_US
    @B-NANA_US 4 месяца назад +2

    You gotta love it when only outdated youtube tutorials are your only source of doing something and the creator never says it outdated

    • @TechWithTim
      @TechWithTim  4 месяца назад +2

      Well at the time of filming it wasn’t outdated?

    • @B-NANA_US
      @B-NANA_US 4 месяца назад +2

      @@TechWithTim just make a pinned comment and I’ll delete the comment, I didn’t expect you to see this lol it’s just that I’ve been going at this for the past 4 hours and gave up just 10 minutes ago

    • @JohnDwightLPaye
      @JohnDwightLPaye Месяц назад

      @@TechWithTim this is pure bait. you never told us anything about the RateLimitError.

  • @drushkyy2017
    @drushkyy2017 7 месяцев назад

    python won't work on my Mac in viscose, idk why. when I click the run button. no code shows on screen. please help

    • @shdwmere
      @shdwmere 7 месяцев назад

      well, seems that you don't know what are you doing at all, have you set environment variables? have you tested the Python IDE?

  • @fredrickomondi6558
    @fredrickomondi6558 7 месяцев назад +1

    The model `gtp-3.5-turbo` does not exist any help plz

    • @renzoblack5944
      @renzoblack5944 7 месяцев назад +3

      It's a spelling error bro. "gpt" not "gtp"

  • @himawaridev
    @himawaridev 6 месяцев назад

    Does it work offline?

  • @godwin1049
    @godwin1049 7 месяцев назад +3

    Much love Tim
    My chatbot throws an error stating there is no attribute called 'ChatCompletion'

    • @amroosman4799
      @amroosman4799 6 месяцев назад

      mine too. did u find a solution?

  • @goatcr7756
    @goatcr7756 2 месяца назад

    How do you learn these much modules

  • @HeetDHAMELIYA-ds1hq
    @HeetDHAMELIYA-ds1hq 2 месяца назад +2

    i'm Still faeing openai=0.28 type error please help

    • @brk.aep7
      @brk.aep7 Месяц назад

      instead of response = openai.ChatCompletion.create use response = openai.completions.create OpenAi removed that on the newer update, I hope this helps.

  • @superpayaseria
    @superpayaseria Месяц назад +1

    Didn't work, and how are we supposed to make these work if we actually make a human or robot or something and depend on these API keys and then it no longer offers the service or something you're pretty much screwed at that point.

  • @MysteryMindset636
    @MysteryMindset636 7 месяцев назад

    when i use api key it shows quota exceed what should i do now ??? how can i run this code

    • @andrewbiadasz6510
      @andrewbiadasz6510 7 месяцев назад

      Same issue here. Might need to use money to toy with this.

  • @Ashraf-sama
    @Ashraf-sama 7 месяцев назад

    huge w

  • @tntclipped
    @tntclipped 4 месяца назад

    HOW DO I COPY THE API KEY??

  • @cxzv3
    @cxzv3 5 месяцев назад

    Is there a way I can make it where can you use my voice and it will reply to me

  • @golden1751
    @golden1751 3 месяца назад

    Am not getting bot respose pls help

  • @wayarberry
    @wayarberry 15 дней назад

    I'm on a paid plan but after just a few attempts got a message saying I exceeded my limits. Not sure what to do, as this program consumes only a trivial amount of resources. Good video though. Thanks

  • @Ubermensch-pt5fi
    @Ubermensch-pt5fi 3 месяца назад

    please i want to run it on colab make a tutorial for it

  • @vihaanshetty
    @vihaanshetty 6 месяцев назад

    it always says rate exceeded

  • @monishraju4789
    @monishraju4789 7 месяцев назад

    Will ai replace developers/programmers/coders?

    • @LaNfinity
      @LaNfinity 7 месяцев назад

      No, actually this profession gets to a higher level.

  • @la009895
    @la009895 7 месяцев назад +1

    now... how the heck do I deploy this to my domain so I can hit this from anywhere :)

    • @bdcash
      @bdcash 7 месяцев назад

      I created a Telegram bot which monitors the chat and uses the ChatGPT api to respond. Advantage is I dodn't need to build a UI. People have also done it with Streamlit.

  • @amarj845
    @amarj845 3 месяца назад

    I'm having issues with deprecated API support. I'm using:
    response = openai.Completions.creatd() along with necessary parameters, but getting an error every time. Is there new syntax for this?

  • @agrodigital92
    @agrodigital92 2 месяца назад

    My code stops just after start .
    import openai
    openai.api_key = "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"
    def chat_with_gpt (prompt):
    response = openai.ChatCompletion.create(
    model = "gpt-3.5-turbo",
    messages =[{"role": "user", "content": prompt}]
    )
    return response.choices[0].message.content.strip()
    if __name__ == "_main_":
    while True:
    user_input - input("You: ")
    if user_input.lower() in ["quit", "exit", "bye"]:
    break
    response = chat_with_gpt(user_input)
    print("Chatbot: ", response)

    • @user-rx3yg5iz3p
      @user-rx3yg5iz3p 2 месяца назад

      Try using this correction , user_input = inp. I think you used - sign.

    • @barshump9891
      @barshump9891 Месяц назад

      do not show ur api key brother. Make a new one