Class: Layered::Assistant::Panel::ConversationsController

Inherits:
ApplicationController show all
Includes:
StoppableResponse
Defined in:
app/controllers/layered/assistant/panel/conversations_controller.rb

Instance Method Summary collapse

Methods included from StoppableResponse

#stop

Instance Method Details

#createObject



25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/layered/assistant/panel/conversations_controller.rb', line 25

def create
  @conversation = Conversation.new(conversation_params)
  @conversation.owner = l_ui_current_user
  @conversation.assistant = scoped(Assistant).find(conversation_params[:assistant_id]) if conversation_params[:assistant_id].present?
  @conversation.name = Conversation.default_name if @conversation.name.blank?

  if @conversation.save
    redirect_to layered_assistant.panel_conversation_path(@conversation)
  else
    render :new, status: :unprocessable_entity
  end
end

#destroyObject



38
39
40
41
# File 'app/controllers/layered/assistant/panel/conversations_controller.rb', line 38

def destroy
  @conversation.destroy
  redirect_to layered_assistant.panel_conversations_path
end

#indexObject



12
13
# File 'app/controllers/layered/assistant/panel/conversations_controller.rb', line 12

def index
end

#newObject



21
22
23
# File 'app/controllers/layered/assistant/panel/conversations_controller.rb', line 21

def new
  @conversation = Conversation.new
end

#showObject



15
16
17
18
19
# File 'app/controllers/layered/assistant/panel/conversations_controller.rb', line 15

def show
  @messages = @conversation.messages.includes(:model).by_created_at
  @models = Model.available
  @selected_model_id = @messages.last&.model_id || @conversation.assistant.default_model_id || @models.first&.id
end