Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/app/docs/streaming-chat/page.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ nextjs:
description: Add a messaging stream.
---

This guide will walk you through adding a ChatGPT-like messaging stream to your Ruby on Rails 7 app using ruby-openai, Rails 7, Hotwire, Turbostream, Sidekiq and Tailwind. It's based on [this gist](https://gist.github.com/alexrudall/cb5ee1e109353ef358adb4e66631799d).
This guide will walk you through adding a ChatGPT-like messaging stream to your Ruby on Rails 8 app using ruby-openai, Rails 8, Hotwire, Turbostream, Sidekiq and Tailwind. It's based on [this gist](https://gist.github.com/alexrudall/cb5ee1e109353ef358adb4e66631799d).

---

Expand Down Expand Up @@ -68,7 +68,7 @@ The chat migration should look like:
```ruby
# db/migrate/20230427131800_create_chats.rb
# bin/rails generate migration CreateChats user:references
class CreateChats < ActiveRecord::Migration[7.0]
class CreateChats < ActiveRecord::Migration[8.0]
def change
create_table :chats do |t|
t.references :user, null: false, foreign_key: true
Expand All @@ -84,7 +84,7 @@ The messages migration:
```ruby
# db/migrate/20230427131900_create_messages.rb
# bin/rails generate migration CreateMessages chat:references role:integer content:string
class CreateMessages < ActiveRecord::Migration[7.0]
class CreateMessages < ActiveRecord::Migration[8.0]
def change
create_table :messages do |t|
t.references :chat, foreign_key: true
Expand Down Expand Up @@ -119,7 +119,7 @@ and the Message model:
class Message < ApplicationRecord
include ActionView::RecordIdentifier

enum role: { system: 0, assistant: 10, user: 20 }
enum :role, { system: 0, assistant: 10, user: 20 }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


belongs_to :chat

Expand Down Expand Up @@ -168,6 +168,8 @@ Add the Chat controller:
```ruby
# app/controllers/chats_controller.rb
class ChatsController < ApplicationController
respond_to :html
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise it fails with In order to use respond_with, first you need to declare the formats your controller responds to in the class level..


before_action :authenticate_user!
before_action :set_chat, only: %i[show]

Expand Down