Class: Plain::MessagesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Plain::MessagesController
- Defined in:
- app/controllers/plain/messages_controller.rb
Constant Summary collapse
- PER_PAGE =
10
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
21 22 23 24 25 26 |
# File 'app/controllers/plain/messages_controller.rb', line 21 def create @conversation = Plain::Conversation.find(params[:conversation_id]) @question = params[:message][:content] @conversation..create(role: "user", content: @question) @conversation.add_assistant_response_async(@question) end |
#index ⇒ Object
9 10 11 12 13 14 |
# File 'app/controllers/plain/messages_controller.rb', line 9 def index @conversation = Plain::Conversation.find(params[:conversation_id]) @current_page = params[:page].to_i @next_page = @current_page + 1 @messages = @conversation..limit(PER_PAGE).offset(@current_page * PER_PAGE).order(created_at: :desc) end |
#new ⇒ Object
16 17 18 19 |
# File 'app/controllers/plain/messages_controller.rb', line 16 def new @conversation = Plain::Conversation.find(params[:conversation_id]) @message = @conversation..new end |