Write A ChatGPT Chatbot With Node.js

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ก.ย. 2024

ความคิดเห็น • 101

  • @readToLearnWeb
    @readToLearnWeb ปีที่แล้ว +1

    Traversy Media's Node.js and OpenAI tutorial is gold! Clear steps from setup to chat completion (18:49). User input, API key (5:26), and history storage (22:13) well explained. A must-watch guide! 🌟

  • @gbengaomoyeni4
    @gbengaomoyeni4 ปีที่แล้ว +2

    Hi Brad, first, thanks for this tutorial. It took me a long time to figure out making it remember the previous conversation contextually. Using chat History is brilliant. Secondly, it is like you are busy with other businesses these days and you don't have much time for tutorials. Please come back fully. You are the KING of programming tutorials on the web. Give us tutorials on private models that can rival ChatGPT itself like: `LLAMA 2 by meta - absolutely free private model and it's like having the entire chatgpt on your local system`, `OPENLLM - also works brilliantly like llama 2`. Please go fully into creating tutorials on these models. They are hotcakes right now. Thanks a mill.

  • @dzalev1
    @dzalev1 ปีที่แล้ว +24

    Frst comment! I owe you my career to you my friend! All the best to you and your family ❤

    • @TraversyMedia
      @TraversyMedia  ปีที่แล้ว +6

      Thanks so much ❤

    • @dzalev1
      @dzalev1 ปีที่แล้ว +3

      @@TraversyMedia ❤️

    • @igorcweb
      @igorcweb ปีที่แล้ว +2

      Same here!

    • @vlee9275
      @vlee9275 ปีที่แล้ว +1

      yeah, Brad helped me a lot too!

    • @lemoncurdfizz
      @lemoncurdfizz ปีที่แล้ว +1

      Me to ❤

  • @hervetshombe356
    @hervetshombe356 ปีที่แล้ว +3

    Thank you so much Brad much appreciated, happy to take your courses, on your website, Udemy or here on youtube it always stands out.

  • @neenus
    @neenus ปีที่แล้ว +7

    Great video as always! I think it's worth mentioning that a paid openai account is required to get it to work. openai api is no longer free unfortunately

    • @faintsignal
      @faintsignal ปีที่แล้ว

      Yes, it was a little frustrating to find this out the hard way.
      Also, OpenAI's API billing page is difficult to decipher. :(

  • @JimKernix
    @JimKernix ปีที่แล้ว +3

    That was really cool! Saving to a log file would be ideal for material for blogs/articles, or for really anything you are interested in.

  • @accountabilitypartnerscomm7635
    @accountabilitypartnerscomm7635 ปีที่แล้ว

    With your initiative and skill as a computer programmer, you deserve a full ride scholarship to the best computer science department in the united States all the way through to the Ph.D.

  • @miggu
    @miggu ปีที่แล้ว +3

    Excellent tutorial, I would avoid using a while loop and would use recursive calling of a chatloop function, recursive functions are non-blocking. They allow Node.js to execute other tasks while waiting for asynchronous I/O operations to complete. Thus, recursive functions can be a better choice to handle heavy computation jobs in order to maintain the responsiveness and scalability of the application. However, please note that you also need to be cautious with recursive functions because if not handled properly, it might cause "RangeError: Maximum call stack size exceeded"... that's the only issue I see here :) again thanks for the time and all the effort an dediation to this incredible channel

  • @mohitsaud2071
    @mohitsaud2071 ปีที่แล้ว

    Was getting bored and this video came. Thanks Brad.

  • @codigomovil
    @codigomovil ปีที่แล้ว +2

    Great video Brad!! 🎉

  • @jeffsuddaby4788
    @jeffsuddaby4788 ปีที่แล้ว

    What an eye-opener! This gives me a core foundation to start learning how ChatGPT works. Is there a way to run this chatbot with GPT-4?

  • @fangthedog
    @fangthedog ปีที่แล้ว +6

    Unfortunately, the API does not work with a free account. Brad, I was trying to breakdown the cost but I found it a little confusing.. Would it cost a lot to create this project having to add a payment?

    • @mohitsaud2071
      @mohitsaud2071 ปีที่แล้ว

      Bro, you can create a new openai account and generate API key, if you are getting max error.

  • @dawid_dahl
    @dawid_dahl ปีที่แล้ว

    Looking forward to the Function Calling video!

  • @abdelrahmansayed4727
    @abdelrahmansayed4727 ปีที่แล้ว

    most Amazing, Helpfull tutorials❤

  • @labinotsulejmani1137
    @labinotsulejmani1137 ปีที่แล้ว +2

    You my man, are a legend! I was just doing something with python and this comes on time!!

    • @isrealoparanti272
      @isrealoparanti272 ปีที่แล้ว

      Sorry! But what does python has to do with this

    • @labinotsulejmani1137
      @labinotsulejmani1137 ปีที่แล้ว

      @@isrealoparanti272i am writing a chatbot in python and this gives me a very good overview? What sounds so alien to this? Maybe you are a newbie. In that case i would understand.

  • @xgskrillax
    @xgskrillax ปีที่แล้ว

    I should do a video showing how i built one using vanillajs on frontend with express webservice. I have some cool ways of engineering the prompt that you could apply here

  • @apex095
    @apex095 ปีที่แล้ว +2

    Hi Brad, when do you plan to add premium docs to your React front to back course ? I am desperately waiting for that. Premium docs are simply amazing.

    • @TraversyMedia
      @TraversyMedia  ปีที่แล้ว

      When I update it in a few months

  • @mohitsaud2071
    @mohitsaud2071 ปีที่แล้ว

    Thank you, great tutorial.

  • @AbuSufian-lo2ub
    @AbuSufian-lo2ub ปีที่แล้ว

    Thank you so much sir....keep up the good work❤

  • @osmanbilgin6637
    @osmanbilgin6637 11 หลายเดือนก่อน

    Thank you for this helpful tutorial on creating A ChatGPT Chatbot With Node.js! I truly appreciate the guidance and assistance provided by the ChatGPT bot, which has helped me generate this comment.

  • @oladunjoyepamilerin4443
    @oladunjoyepamilerin4443 ปีที่แล้ว +3

    Thank you so much Brad for this legend tutorials ❤
    Though my output is given me 429 error code pls how can I resolve this

    • @oladunjoyepamilerin4443
      @oladunjoyepamilerin4443 ปีที่แล้ว +1

      I Have resolved this issue 😊

    • @jeAshutoshSingh
      @jeAshutoshSingh ปีที่แล้ว +1

      @@oladunjoyepamilerin4443 can you tell me how you resolved please

    • @oladunjoyepamilerin4443
      @oladunjoyepamilerin4443 ปีที่แล้ว

      @@jeAshutoshSingh it turns out there were too many requests on my openai account where you will get the keys so I create a new account and get a new key and everything start working

  • @sampurnachapagain2936
    @sampurnachapagain2936 ปีที่แล้ว +3

    Thanks for this tutorial, Brad. I want to do something similar in Python.

    • @TraversyMedia
      @TraversyMedia  ปีที่แล้ว

      I plan on creating the same in Python soon

  • @dev4g276
    @dev4g276 ปีที่แล้ว +2

    sir love your content can you make part 2 for front end of this application?

    • @TraversyMedia
      @TraversyMedia  ปีที่แล้ว +2

      This was meant to be a CLI app, but I can make something similar in the browser

  • @partydoo
    @partydoo 5 หลายเดือนก่อน +2

    Configuration in openai?
    Got an error!
    import { Configuration, OpenAIApi } from 'openai';
    ^^^^^^^^^^^^^
    SyntaxError: The requested module 'openai' does not provide an export named 'Configuration'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:132:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:214:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
    at async loadESM (node:internal/process/esm_loader:28:7)
    at async handleMainPromise (node:internal/modules/run_main:113:12)
    Node.js v20.11.1
    What do I have to do? My installed openai Version is 4.32.1
    Thank's for assistance in advance!

    • @jamilafzal9501
      @jamilafzal9501 3 หลายเดือนก่อน

      same here

    • @joaomdiaspinto
      @joaomdiaspinto 2 หลายเดือนก่อน

      My solution:
      import { OpenAI } from 'openai';
      import dotenv from 'dotenv';
      dotenv.config();
      const openai = new OpenAI({
      apiKey: process.env.OPENAI_API_KEY
      });
      async function main() {
      const chatCompletion = await openai.chat.completions.create({
      model: 'gpt-3.5-turbo',
      messages: [{ role: 'user', content: 'Say this is a test' }],
      });
      console.log(chatCompletion);
      }

  • @chris-zlrr
    @chris-zlrr ปีที่แล้ว

    Once again a great vid

  • @muhammedozalp
    @muhammedozalp 11 หลายเดือนก่อน

    Thank you bro

  • @shrinjoysaha
    @shrinjoysaha 11 หลายเดือนก่อน

    Great video.

  • @guilhermedinizdosreisgomes5030
    @guilhermedinizdosreisgomes5030 ปีที่แล้ว

    brad you should really do a python video, best instructor for beginners

  • @NurlanGuliyev-u8d
    @NurlanGuliyev-u8d 2 หลายเดือนก่อน

    Well Done!

  • @herbertk9266
    @herbertk9266 ปีที่แล้ว

    Thank you

  • @dgloria
    @dgloria ปีที่แล้ว

    hi Brad, this is great. Is it possible to hit that api from postman? And how do I train the api to my company's knowledge base?

  • @KarnatakaTraderBN
    @KarnatakaTraderBN 6 หลายเดือนก่อน +1

    The requested module 'openai' does not provide an export named 'Configuration'----- I am getting this error help me out

    • @Afrodafro
      @Afrodafro 6 หลายเดือนก่อน

      do "npm install openai" lil bro

    • @Priyanka2k01
      @Priyanka2k01 6 หลายเดือนก่อน +1

      You can use like this if you didn't use "type":"module" in package.json file
      const OpenAIApi = require("openai");
      const Configuration = require("openai");

  • @N5O1
    @N5O1 ปีที่แล้ว

    Does anyone know, how to use the GPT API to summarize the last question in the context of conversation? For example:
    -- What is the tallest building in the world?
    -- Burj Khalifa.
    -- Where is it located?
    and in this case it should not answer, but say something like:
    "User wants to know where the Burj Khalifa is located".
    Or echo the question if it's not a complex one.

  • @ExitStrategyNYC
    @ExitStrategyNYC ปีที่แล้ว

    at @21:15, why not just put console.log(colors.green('Bot: ') + completionText). onto line 21 above the if statement rather than repeating it twice?

  • @user-lj6np3vu4y
    @user-lj6np3vu4y ปีที่แล้ว

    please make videos on mirth connect plz🙏

  • @augustuscaeser8939
    @augustuscaeser8939 ปีที่แล้ว

    can you make a video on powershell and powershell scripting?

  • @enotechtv
    @enotechtv ปีที่แล้ว

    Tremendous but so much the better if it will have the UI/UX not only working on the console.

  • @igorcweb
    @igorcweb ปีที่แล้ว

    Amazing!

  • @karaninfotech6755
    @karaninfotech6755 ปีที่แล้ว

    Hi Brad, you mentioned model like 'gpt-3.5-turbo' where did you get this model, can you please explain it ?

  • @maduemeka6982
    @maduemeka6982 ปีที่แล้ว

    My hero❤❤

  • @jellycoding
    @jellycoding ปีที่แล้ว

    At 26:40 you get an answer and I get a different answer... lol
    I get:
    "According to data from the United States Census Bureau in 2020, the estimated population of Tallahassee, the capital of Florida, is approximately 198,000."

  • @user-nz8rn8hv2m
    @user-nz8rn8hv2m ปีที่แล้ว

    I'm getting an error saying socket connection timeout evertime I try to test console.log(chat completion)

  • @kshitija2606.
    @kshitija2606. 7 หลายเดือนก่อน

    TypeError: Cannot read properties of undefined (reading 'choices')
    How to solve this?

  • @05Boy96
    @05Boy96 ปีที่แล้ว

    Sir which course should I do so that I can get a good job soon

  • @ajayadav09
    @ajayadav09 ปีที่แล้ว

    Amazing stuff!

  • @05Boy96
    @05Boy96 ปีที่แล้ว

    sir i have passed BA now what should i learn and how to get job soon

  • @25569
    @25569 ปีที่แล้ว

    Thanks. Why do you use seperare variable messages if you can save all history in arrays of obects in history and do not convert it from array of arrays each iteration?

    • @omsatpathy5455
      @omsatpathy5455 ปีที่แล้ว

      could u use the API or do we have to have a paid subscription?

  • @prakharsoni3495
    @prakharsoni3495 หลายเดือนก่อน

    how can I make it with webSocket?

  • @fatihcnar3513
    @fatihcnar3513 ปีที่แล้ว +1

    Getting this error
    Request failed with status code 429

    • @PrithaDas-oq9dj
      @PrithaDas-oq9dj 6 หลายเดือนก่อน

      could you solve this error?

  • @cristianmc9464
    @cristianmc9464 ปีที่แล้ว

    Hi! I have been studying JavaScript for some time, I know quite a lot about the basics of this language, but when it comes to creating a task, I get stuck. I think that this is due to vision and thinking. I have tried many small applications such as "To do List", "Calculator", "Timer" and they seem very simple when I look at the tutorial, but when I try to create them myself I cannot succeed. I don't have the same problem with HTML and CSS. How could I solve this problem? I await your suggestions and opinions. Thank you!

    • @moeinsamani1467
      @moeinsamani1467 ปีที่แล้ว

      Basically it happens to all of us, but the difference is the scale of the problem we are facing. the key is to never your passion, and keep going. try to code and code and code even with mistakes, and then try to find your bugs and solve it. in this case you will bump up your knowledge and get confidence. dont worry. slow and steady wins the race

  • @druggero77
    @druggero77 ปีที่แล้ว

    Gave $5.00 in token credits, but they expired the same day. So to continue you need to setup a paid account. Has anyone done this yet. Brad, do you have any more info on this?

  • @Chinguhz
    @Chinguhz 7 หลายเดือนก่อน

    From my understanding, openai no longer offers a free API key. I could be incorrect, let me know!

    • @digvijaysingh6882
      @digvijaysingh6882 6 หลายเดือนก่อน

      yeah, you seem right

    • @the_yugandharr
      @the_yugandharr 6 หลายเดือนก่อน +1

      your chatgpt usage counts towards the your account quota. just create a new account and you're good to go!

  • @Atibhoyanok
    @Atibhoyanok ปีที่แล้ว +1

    I wright to chat GPT to Suggest a bats TH-cam channel for Learning web development. and Chat GPT Suggest your Channel.

  • @aabhishakemishra
    @aabhishakemishra ปีที่แล้ว

    Great job 😊

  • @aricwilliamsdeveloper
    @aricwilliamsdeveloper ปีที่แล้ว +2

    I'm 1st to say, this was right on time!

  • @AamirKhan-de7hg
    @AamirKhan-de7hg 5 หลายเดือนก่อน

    Is the Chat-gpt API free to use ?

  • @Godislove011
    @Godislove011 ปีที่แล้ว

    chatgpt api shows error of insufficient quota is there any solution?

    • @shubhrajit2117
      @shubhrajit2117 5 หลายเดือนก่อน +1

      Sign up with new account and phone

  • @aswin6261
    @aswin6261 ปีที่แล้ว +3

    it not working for the free account. only paid users can go to this heaven.

  • @shubhrajit2117
    @shubhrajit2117 5 หลายเดือนก่อน

    He has made the chat history overly complicated..
    Here's a simpler version:
    import 'dotenv/config'
    import OpenAI from 'openai'
    import promptSync from 'prompt-sync'
    const input = promptSync()
    const openai = new OpenAI({ apiKey: process.env.API_KEY })
    const chat_history = []
    while (1) {
    const usr_input = input('User: ')
    chat_history.push({ role: 'user', content: usr_input })
    let completion = await openai.chat.completions.create({
    messages: chat_history,
    model: 'gpt-3.5-turbo',
    })
    const bot_output = completion.choices[0].message.content
    console.log('Bot:', bot_output)
    chat_history.push({ role: 'assistant', content: bot_output })
    if (usr_input.toLowerCase().includes('bye')) {
    break
    }
    }

  • @MYount
    @MYount ปีที่แล้ว

    First: me
    Second:chatbot

  • @vivekrahul
    @vivekrahul ปีที่แล้ว

    Do we need paid API key ?

    • @N5O1
      @N5O1 ปีที่แล้ว

      you can check it in your account, if you have a free deposit, then you don't Otherwise you need to pay for usage

  • @nmugumya
    @nmugumya ปีที่แล้ว

  • @muhammadubaid6576
    @muhammadubaid6576 ปีที่แล้ว

    Make AI based Chatbot in MERN stack with FAQs

  • @FindYourWhyInLife
    @FindYourWhyInLife ปีที่แล้ว

    api is not free

  • @FuzzyAnkles
    @FuzzyAnkles ปีที่แล้ว

    I thought it was miami

  • @Zagoorland
    @Zagoorland ปีที่แล้ว +2

    To be honest I'm a little bit tired of seeing AI and ChatGTP content everywhere, it's like everybody is posting content about because of being afraid of staying behind... Like, I've seen too many videos about using OpenAI API, like come on, you can be better than this

    • @kalenzo78
      @kalenzo78 ปีที่แล้ว +4

      Mind the tone and the person you are talking to :- since you have a youtube channel, i think it will be better if you upload what you like there next time

    • @ITSH4WK
      @ITSH4WK ปีที่แล้ว +4

      Uhh.. ok? Don't watch it then?

    • @Zagoorland
      @Zagoorland ปีที่แล้ว +2

      @@kalenzo78 Okay, i didn’t wanted to be rude. I love Brad videos and he’s a great teacher. Maybe I feel just a little overwhelmed of the current state of things. Also my current mental state isn’t the best, so that affected how I sound.
      So if you’re reading this Brad I’m sorry if my comment hurt you. That wasn’t my intention.

  • @PenguinCrayon269
    @PenguinCrayon269 ปีที่แล้ว +1

    i learned a lot from this channel. but this is too buzzword-y.

  • @alpharomeo15
    @alpharomeo15 ปีที่แล้ว

    Good to see you're at least using a real computer, i.e. Macintosh versus that bunch of crap they call a PC (Piece a Crap) along with that asinine crappy Microsucks OS! !

  • @ColdmindDev
    @ColdmindDev 5 หลายเดือนก่อน

    WOOOOW!!! "Write A SkyNet ChatGPT Chatbot With Node.js" morphs into "Echo Crafting via REST API" - I added SkyNet since, well you a re on to something here...
    From cutting edge to please hit me with a...
    I have something in the workshop we could collaborate on ?
    You handle crafting a hardcoded graph database with every imaginable word and interaction, including sensor inputs.
    try {
    if (sensor.underwear.match("biker1")) {
    voiceBox.say("I need your clothes, your boots, and your motorcycle").then(res => {
    if (res.respectfulness < 50) {
    actionSuggester.addWithPriority("throw biker1 on grill");
    // A/B testing recommended for the following segment
    if (res.respectfulness < 90) {
    voiceBox.say("Hasta la vista, baby.");
    }
    }
    });
    }
    } catch (e) {
    voiceBox.say("I'll be back.");
    }
    Let's compile the combos for our SkyNet FoxPro vault. Deal?
    Please let me know and have a great day! (FBI will probably read this post so PM instead)