How To Integrate Chatgpt With Rails 7: Step-by-step Tutorial

preview_player
Показать описание
In this video I will go through making a Ruby on Rails frontend/middle-tier that will talk to OpenAI’s API. All of this will let you mimic what the ChatGPT website does.

This code will:

- Let you create/manage users by hooking in Devise
- Let you create conversations with ChatGPT that are assigned to a user
- Let you save and retrieve these conversations so that they can be continued at any time.

As I have tried to keep this on target I am not doing any error checking, nor am I doing the stuff we don’t specifically need for this (logging out, creating users via UI, etc etc). I leave that as an exercise to the reader!

Timestamps

00:00 Intro
00:50 Create app
02:02 Install devise
03:30 Add seed data
04:00 Add docker
05:00 Add dotenv-rails, .env file
09:00 Start the database
10:35 Create chat object, controller, views (scaffolded)
13:20 devise: force account and make better looking
16:20 add ruby-openai
17:15 OpenAI access token
18:50 create views
21:30 work on controllers to create the chat
23:30 turbo_streams
29:20 chat index
31:00 chat view (finally!)
36:20 Talking to OpenAI
43:40 How to continue the conversation
46:30 save the raw response
47:05 fix the sidebar list
48:20 Conclusion - tips for a product

### Source code and notes 🗳
This is a 'pay what you want' item, meaning you can get it for free. But any payment is really appreciated as it helps me transition to creating great content like this full-time!

### Talk to me!

Looking for great hosting? I've been using DigitalOcean for 7 years and they have never let me down. Amazing.

#techEntrepreneur #entrepreneurship #softwareDevelopment
Рекомендации по теме
Комментарии
Автор

Good moorning uncle smy, lets go pratice.

viniciusrvieira
Автор

Thank you very much for this video. Thanks to it I was able to successfully add the ChatGPT feature to my personal app. Wishing you good health and continue to make good videos. Best regards

stone_anh
Автор

This was great. Please could you do a tutorial on using chatgpt on rails dataset? Example using chatgpt to search through a list of personal data on the you in advance

richillartloe
Автор

Thank you very much for this walkthrough.

No worries about pasting the code for the view. It is actually welcomed... best to get that design part out of the way to get to the good stuff. 🙏

KrishnaDiamesso
Автор

great video, thanks for share with us, you can use collection and change the name of the object with as argument

haroldpepete
Автор

Hi @PhilSmy I hope you can simply turn it into a gem install it configure it here you go, you will have your Open AI interface, In configuration you just ask for the OpenAI access token, A little bit of more UI work and then we are done. Please let me know if you want it that way.

nitanshuverma
Автор

Could you please share the code on github and the link in your description. Thanks uncle Smy!

abdu
Автор

i face the error while go through the step and the error say the "Failed after 5 retries: the server responded with status 429" and belive me i have watched the same episode to many time but still same issue please someone there to help me out iwll be greatful for me to use this as a my first ai project

vishalsinghrathore
Автор

Instructions are very useful. Let me ask, if the [ Client API Server OpenAI ], then how can the API Server return a stream message to the Client? Because if we wait for the AI to finish thinking and then return the result once, users will feel like they are waiting for the answer for a long time.

MinhTang-oubp
Автор

Why aren’t you using rails credentials? Also Ruby 3.3.4 comes automatically with Docker and you did not include a docker ignore file

martinWein
Автор

UI is not working for me, Can u please provide me solution

xeezywg
Автор

Can you post the github link for this?

almortada
Автор

i face the error while go through the step and the error say the "Failed after 5 retries: the server responded with status 429" and belive me i have watched the same episode to many time but still same issue please someone there to help me out iwll be greatful for me to use this as a my first ai project

vishalsinghrathore