How to use the OpenAI Assistants API (Discord Bot Tutorial)

Поділитися
Вставка
  • Опубліковано 1 гру 2024

КОМЕНТАРІ • 90

  • @dd2834
    @dd2834 Рік тому +2

    Just discovered your channel and subscribed - Will be going through your example myself to connect an Agent to Discord.

    • @VoloBuilds
      @VoloBuilds  Рік тому +1

      Thanks for watching! Best of luck with your implementation!

  • @Suushidesu
    @Suushidesu 10 місяців тому +3

    wow this was such a good to follow tutorial, any plans for another one that shows how to incorporate a seperate database like an obsidian vault that the AI can use for thread pointers? im really excited to implement this into my server but im so scared to have everyone bond with it only to lose its context every reload/reboot

    • @VoloBuilds
      @VoloBuilds  10 місяців тому +1

      Thank you so much! That is a good point - and I've heard other concerns too which relate to not being able to send multiple messages at the same time. I didn't have plans to make a second one yet, but will have to think about it :)

    • @Suushidesu
      @Suushidesu 10 місяців тому

      @@VoloBuilds right! We've been experimenting on that other problem by including something like "# user:name" in every message a human sends in the server but that's not a long term solution anyway unless that's automated.
      Anyway I appreciate your response and am keeping my eye on your channel for updates on this and your other projects c:

    • @Suushidesu
      @Suushidesu 10 місяців тому +1

      @@VoloBuilds some progress was made and since this tutorial started the whole endeavour i figured id give a little update: for longterm context we now have the bot write locally to a thread pointer file, which contains the id for the discord channel and links it to specific threads.! It works really well and its now reboot and crash proof 🙏 thanks again volo. I really appreciate what you tought us!

    • @VoloBuilds
      @VoloBuilds  10 місяців тому

      Hey that's a really good idea@@Suushidesu! Yeah I think a local file is a perfectly good solution - especially if you don't have like thousands of users or something. If it got too high, you could start to use a distributed database, but I love that you chose a less complicated solution first! Glad to hear your project is going well!

  • @Queeny.photography
    @Queeny.photography 8 місяців тому

    Thanks a lot! Followed all your instructions to the T after failing and wasting time checking out other blogs and tutorials. You Rock! I have my own custom bot installed now. Wondering if you made a video on the sessions / user / thread database storage? I would love to be able to accomplish that now.
    Thanks again!

    • @VoloBuilds
      @VoloBuilds  8 місяців тому

      That's awesome! Glad it was helpful! :) I haven't made that follow-up and probably won't at this point so it's a good opportunity to challenge your skills and expand on this code!

  • @SouthbayCreations
    @SouthbayCreations 29 днів тому +1

    This is a great video! Have you considered maybe making another discord bot using Cursor? Thanks again for all the tutorials!

    • @VoloBuilds
      @VoloBuilds  28 днів тому +1

      That might be fun to revisit at some point! The assistants API is still unmatched in terms of developer experience and friendliness - so I would still use it but could rebuild with Cursor :)

    • @SouthbayCreations
      @SouthbayCreations 27 днів тому

      @@VoloBuilds A tutorial using Cursor to build the Discord bot with the assistants API would be amazing and super helpful! Thanks for everything!!

  • @bleak183
    @bleak183 Рік тому +1

    I've been waiting for someone to make a video like this!! do you have a discord server?

    • @VoloBuilds
      @VoloBuilds  Рік тому +1

      Glad you enjoyed it! I don't but that's a great idea, so I'll be making one in the coming weeks! :)

  • @illlillilllill409
    @illlillilllill409 3 місяці тому +1

    @volo Great tutorial, thank you! Can you provide an update in the Git for the V2. For some reason I don't get it to work using the V2 header for example. That would be amazing!

    • @VoloBuilds
      @VoloBuilds  3 місяці тому

      Hey! Thanks for watching - I haven't played around with V2 just yet. I am not very active in maintaining (sorry, just too much stuff going on 😅) but if you make a small PR that addresses the specific issue I am happy to merge

    • @OsamahAskari
      @OsamahAskari Місяць тому

      @@VoloBuilds Hey, great video thankyou so much! Just to popup about the question that was asked by @illlilllilllill409, you will need to remove the older openai module from the package lock file and allow updated packages for it to work with V2 header, alternative to that would be using axios and following the v2 documentation on openai documentation, works both ways!

  • @satchserra89
    @satchserra89 10 місяців тому +2

    Great tutorial!! My assistant works great on my server! idk ANYTHING about coding and was able to get it up and running!
    That being said, i am now stuck on something 😂Im running this out of vscode on my desktop and was wondering if theres a way to have it work without my pc being on.

    • @VoloBuilds
      @VoloBuilds  10 місяців тому

      That's awesome!! Glad you were able to get it working! I would look into Replit as a potential platform for more or less easily deploying/hosting a bot like this!

    • @Queeny.photography
      @Queeny.photography 8 місяців тому

      Is Replit better than Google Cloud? I am also a newbie and don't know much about this. I want to create a database for the sessions and threads as well. @@VoloBuilds

  • @nosult3220
    @nosult3220 Рік тому +2

    I made a discord bot with mistral 7B (using a drop in for the open ai code) yes this makes it so much easier with the threads

    • @VoloBuilds
      @VoloBuilds  Рік тому +1

      Nice!! I'd love to see an open source version of these abstractions. They make a lot of sense to me. Perhaps LangChain will pivot towards this? Or perhaps someone will build something new? Good opportunity here

  • @illya_ike
    @illya_ike 7 місяців тому

    I'm not sure I get how Discord accesses your bot which, from what I understand, is running on your local machine. Could you please clarify this point?

    • @illya_ike
      @illya_ike 7 місяців тому +1

      Got it - your bot keeps opened connection with the Discord server - this way it can handle requests.

  • @Fever_Dreams_
    @Fever_Dreams_ 11 місяців тому

    This was working great for me, but I changed the OpenAI API key, and the program isn't seeing the new key. It tries to use the old one, which is rejected every time because it's been deleted. Any idea how to fix this?

    • @VoloBuilds
      @VoloBuilds  11 місяців тому

      Hey there - where are you running the code? If you deployed it to a cloud service or something make sure the env change is present there as well. Either way, make sure to restart the application after making .env changes for them to take effect

  • @Leyverse
    @Leyverse 4 місяці тому +1

    GREAT +1 SUB

  • @dylanbritz1333
    @dylanbritz1333 Рік тому +2

    This video helped a lot thanks man! Can you make a tutorial on how to upload files and access them as well?

    • @VoloBuilds
      @VoloBuilds  Рік тому

      Glad it was helpful!! Yes! This is one of the videos I plan to create in the near future :)

    • @dylanbritz1333
      @dylanbritz1333 Рік тому

      @@VoloBuilds Awesome I can't wait! I have files uploaded to the Assistant ID I used for this bot, but for some reason every time I create a prompt to access the files, the bot can't access all of the files and it takes forever to respond. I did manage to create split messages in my code tho which is pretty cool, when the bot gets close to a 2000 characters it's splits the message in 2

    • @VoloBuilds
      @VoloBuilds  Рік тому

      @@dylanbritz1333 Sounds like I'm in for some deep exploration working with the files then lol! Hey that's a brilliant idea with the message split! Would be happy to merge into my repo if you want to make a PR ;)

    • @dylanbritz1333
      @dylanbritz1333 Рік тому

      @@VoloBuildsI'd be honored to! But by implementing that solution I encountered another problem, every time I give the bot a message it responds with 2 messages 🥲 I'm still pretty much a rookie when it comes to coding but ChatGPT has been a massive help 😂

    • @VoloBuilds
      @VoloBuilds  Рік тому

      Haha yes ChatGPT can be such a great way to learn this stuff! If you do get it working, feel free to open that PR!

  • @onedaytimewin
    @onedaytimewin Рік тому

    fire tutorial, thank you

  • @GamesBrendanPlays
    @GamesBrendanPlays Рік тому

    Hey! So I was able to get a discord bot going real quick, but the bot shuts down if there are two requests sent before it answers the first one. Is there an easy way to fix this?

    • @VoloBuilds
      @VoloBuilds  Рік тому

      Oh that's interesting - I wonder why that would happen.. If you don't mind, could you open an issue on GitHub with the details of what you're seeing? I could take a look then and see if I can reproduce it!

  • @mracing369
    @mracing369 10 місяців тому

    Hi! thanks for the tutorial, I got the bot working! I didn't implement the changes after 17:20, but the bot seems to be working fine without it. am I missing something?

    • @VoloBuilds
      @VoloBuilds  10 місяців тому

      I think the bot can work without those changes but depending on what you wrote, you might be missing the relevant context of the full thread. I linked the code in the description, so you could check it out there if you're still not sure!

    • @mracing369
      @mracing369 10 місяців тому

      your github code worked straight away so i ended up using that anyway :) @@VoloBuilds

  • @101thornangel
    @101thornangel 9 місяців тому

    Is there any way to limit the amount of token usage?

    • @VoloBuilds
      @VoloBuilds  9 місяців тому

      You would need to implement this in your backend server logic - probably by adding a token counter and then tracking overall usage in your DB. OpenAI has been improving this side of things though so I wouldn't be surprised if they add a native feature to do this in their platform at some point!

  • @jagatla_vyakti
    @jagatla_vyakti Рік тому +1

    Once GPT store is live please make a video on GPT store and how to create custom GPT, love from india

    • @VoloBuilds
      @VoloBuilds  Рік тому +1

      Absolutely! OpenAI actually unlocked custom GPT creation for everyone yesterday so (even though the store doesn't exist yet) so I'll be building a custom GPT in one of my next couple of videos! Thanks for watching!

  • @chriswilke9197
    @chriswilke9197 Рік тому +1

    Could do a similar video or plugin for Slack?
    This was a great tutorial. Thank you!

    • @VoloBuilds
      @VoloBuilds  Рік тому +1

      Great suggestion - I got a few more videos planned out currently but will add this to the idea list! Thanks for watching!

    • @patherren3487
      @patherren3487 9 місяців тому

      @@VoloBuilds I'm gonna second this comment. A slack integration would be extremely helpful within the business!

  • @CanuteTang
    @CanuteTang 8 місяців тому

    Hi Volo, I have create a discord bot, and used your openAI assistant code. Also I upload my knowledge base for it. But it seems have a large usage, just 2~3 questions, 1 $ used....Is that normal?

    • @VoloBuilds
      @VoloBuilds  8 місяців тому

      That seems likely to be related to the knowledge base size. They have the cost for that published and it's kind of confusing. $1 for 2-3 questions seems high unless you have this thing pumping out a huge amount of output

    • @CanuteTang
      @CanuteTang 8 місяців тому

      @@VoloBuilds thanks for your feedback! Very helpful! I did upload a huge knowledge base, even in ppt and picture formats, and I thought I should simplify them? Because every question means searching this huge knowledge base, right?

    • @VoloBuilds
      @VoloBuilds  8 місяців тому

      @@CanuteTang Cleaning up the data before loading is definitely recommended! Both for accuracy and cost purposes. It'll make it easier for the model to find what it needs to use it. The entire knowledge base is not passed into each prompt and the specifics of OpenAI's retrieval approach are not public, but the simple way to think about it is -> more data = more cost, messier data = more cost

  • @mracing369
    @mracing369 10 місяців тому

    One more question, do you have a tutorial to upload files to my assistance API and train it that way?

    • @VoloBuilds
      @VoloBuilds  10 місяців тому

      Yep, I do! ua-cam.com/video/JzxUW0ZT4to/v-deo.html the intro is a bit quirky as I got carried away being creative 😅 but I go over the files API in there!

    • @mracing369
      @mracing369 10 місяців тому

      @@VoloBuilds thanks for your help! i am trying to develop a billing system for my Assistant, but I can't figure out how to get a cost breakdown per Assistant, it just shows a cost breakdown per model. It does show the number of queries per assistant, but not the number of tokens. this seems rather deficient! how would you approach this problem Volo?

    • @VoloBuilds
      @VoloBuilds  10 місяців тому

      @@mracing369 I think this is a limitation of what OpenAI makes available unfortunately. The closest work around I can think of is to add your own logic to count tokens in your code - maybe using something like this: www.npmjs.com/package/@dqbd/tiktoken
      It's not perfect though because you then have to count input/output separately and do the math on the rate, and you have no visibility into how many tokens it used for retrieving data and such. Maybe it's in the API response json? Not trivial for sure! Let me know if you figure something good out

    • @mracing369
      @mracing369 10 місяців тому

      will do@@VoloBuilds! thanks for the response. i am actually looking at mistral ai as a cheaper alternative. also changing to the cgpt 3.5 1160 model helps to save money.

  • @kordou
    @kordou Рік тому

    Hi thank fo the tutorial but you can not folow this tutorial. at the poin that create the bot on discord, there is a missing step and you cannot get the url.
    Solution that i tried is to add aa Redirect URL in the AUTH 2 to a localhost url but then when you try to link the bot with the server the link does not exist so the not never goes into the server,
    any solution ?

    • @VoloBuilds
      @VoloBuilds  Рік тому

      Not sure what you mean exactly. Will try to clarify the steps:
      1. Go to discord.com/developers/applications/
      2. Create app (assuming you got this already done)
      3. Check all 3 "Privileged Gateway Intents" boxes in the Bot tab
      4. Go to Oauth2 > URL Generator
      5. Check the "bot" box (perhaps this is most likely the step you missed?)
      6. URL should appear at the bottom of the page. This URL is the URL you can use to invite the bot to your server
      7. Go to that URL in the browser and add the bot to your server
      Where specifically in this flow are you encountering the issue?

    • @kordou
      @kordou Рік тому

      @@VoloBuilds thanks for the responce. I am doing exactly that but at least in my discord the lest step where getting the URL does not give a url and you cannot press the save button .

    • @VoloBuilds
      @VoloBuilds  Рік тому

      @@kordouHmm that is strange indeed. Seems like a discord problem, maybe with your account? I don't have turbo or anything so I don't think it's that.. Maybe some weird ad block thing? If you want me to take a closer look, please open a github issue with a video attached of what you see when trying to create the discord URL!

  • @iffatarabrishti1623
    @iffatarabrishti1623 10 місяців тому

    why i am not seeing any server while creating a bot in discord??

    • @VoloBuilds
      @VoloBuilds  10 місяців тому +1

      If you're talking about a discord server, you need to create one first - those servers are basically communities you can create. If you're talking about the code shown in this tutorial, you would be running it on your local computer which is effectively acting as a server, but to make it work "in production" you'd need to deploy the code somewhere like Replit

  • @draganpetrov9594
    @draganpetrov9594 Рік тому

    Hi Volo, do you do custom work? Freelancing

    • @VoloBuilds
      @VoloBuilds  Рік тому +1

      I do! Send me an email at volobuilds1 @ gmail and we can talk details

  • @arealicehole
    @arealicehole 11 місяців тому

    how do i go from flowise to discord

    • @VoloBuilds
      @VoloBuilds  11 місяців тому

      I actually have not used flowise myself, just seen tutorials on it from other creators. This tutorial is working with discord directly, so no need to involve flowise. Looks like this tutorial connects discord and Flowise though: ua-cam.com/video/2advCQg3Tcc/v-deo.html&ab_channel=DerekCheung

  • @Fellendorf85
    @Fellendorf85 Рік тому +1

    🔥🔥🔥🔥🔥

  • @zaregotoch.8491
    @zaregotoch.8491 6 місяців тому

    nodemon bot command does not work

    • @VoloBuilds
      @VoloBuilds  6 місяців тому

      Sorry to hear that - what seems to be the issue? Since I can't troubleshoot directly, I've found ChatGPT pretty good at pointing me in the right direction with error messages and such, so I would suggest that

  • @jhuneatienza7160
    @jhuneatienza7160 11 місяців тому

    Yo bud, why is the bot echoing (repeats what I say)

    • @VoloBuilds
      @VoloBuilds  11 місяців тому

      I'm not sure how you have it configured, but perhaps you are using some simplified version of the code without the assistants API hooked up to it? The code posted here (github.com/VoloBuilds/openai-assistants-discord-bot/blob/main/bot.js) should not do that, unless your assistant is configured to repeat whatever is said to it!

  • @RichardGetzPhotography
    @RichardGetzPhotography Рік тому

    Very nice. Thank you for sharing. I send you an email from Getz AI. Look forward to speaking with you.

    • @VoloBuilds
      @VoloBuilds  Рік тому

      Glad you enjoyed the video and thanks for reaching out!!

  • @PabloFMa
    @PabloFMa Рік тому +1

    gm Volo I would like to have your help for a role game on the metaverse :D, how can I contact you? Love what you do

    • @VoloBuilds
      @VoloBuilds  Рік тому

      Hey there Pablo! Sounds pretty cool :) you can get my email on my channel about page: www.youtube.com/@VoloBuilds/about

    • @Fever_Dreams_
      @Fever_Dreams_ 11 місяців тому

      ​@@VoloBuildsI can't see your email on that page.

  • @jayakrishnanp5988
    @jayakrishnanp5988 Рік тому +1

    🌟🌟🌟🌟🌟
    Hey buddy
    Make more exploration in the application of threads and on placing assistants api calls within code when each assistant can run separate parallel threads to completion of any given task and thus
    Enhance a current simple architectural design of any utility applications around ❤
    Note 🌀🌀🌀
    Threads videos are not much in UA-cam for the people to explore and learn
    And you are amazing teacher too
    🫵🫡🫡🫡🖖
    🌍

    • @VoloBuilds
      @VoloBuilds  Рік тому

      Thank you so much!! Really appreciate your ideas!