Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
andreibondarev committed Sep 28, 2024
1 parent 767bcb8 commit 05d4b12
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def create_controller_file
end

def create_view_files
template "assistant/views/_message.html.erb", "app/views/assistants/_message.html.erb"
template "assistant/views/_message_form.html.erb", "app/views/assistants/_message_form.html.erb"
template "assistant/views/index.html.erb", "app/views/assistants/index.html.erb"
template "assistant/views/new.html.erb", "app/views/assistants/new.html.erb"
template "assistant/views/show.html.erb", "app/views/assistants/show.html.erb"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ def chat
private

def assistant_params
params.require(:assistant).permit(:instructions)
params.require(:assistant).permit(:instructions, :tool_choice)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
display: flex;
flex-direction: column;
gap: 5px;
margin-bottom: 15px;
}

.form-group label {
Expand Down Expand Up @@ -227,4 +228,19 @@
color: #333;
text-decoration: none;
display: block;
}

.tool-choice-select {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 16px;
background-color: white;
cursor: pointer;
}

.tool-choice-select:focus {
outline: none;
border-color: #007bff;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div id="<%= dom_id message %>" class="message <%= message.role %>">
<div id="<%%= dom_id message %>" class="message <%%= message.role %>">
<div class="message-content">
<%= message.content %>
<%%= message.content %>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= form_with(model: [@assistant, Message.new], url: chat_assistant_path(@assistant), method: :post, class: "chat-form") do |form| %>
<%= form.text_area :content, class: "chat-input", placeholder: "Type your message..." %>
<%= form.submit 'Send', class: "chat-submit" %>
<% end %>
<%%= form_with(model: [@assistant, Message.new], url: chat_assistant_path(@assistant), method: :post, class: "chat-form") do |form| %>
<%%= form.text_area :content, class: "chat-input", placeholder: "Type your message..." %>
<%%= form.submit 'Send', class: "chat-submit" %>
<%% end %>
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<div class="assistant-list-container">
<h1 class="list-header">Assistants</h1>

<%= link_to 'Create New Assistant', new_assistant_path, class: "new-assistant-link" %>
<%%= link_to 'Create New Assistant', new_assistant_path, class: "new-assistant-link" %>

<ul class="assistant-list">
<% @assistants.each do |assistant| %>
<%% @assistants.each do |assistant| %>
<li class="assistant-item">
<%= link_to assistant.instructions, assistant_path(assistant), class: "assistant-link" %>
<%%= link_to assistant.instructions, assistant_path(assistant), class: "assistant-link" %>
</li>
<% end %>
<%% end %>
</ul>
</div>
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
<div class="assistant-form-container">
<h1 class="form-header">Create New Assistant</h1>

<%= form_with(model: @assistant, local: true, class: "assistant-form") do |form| %>
<% if @assistant.errors.any? %>
<%%= form_with(model: @assistant, local: true, class: "assistant-form") do |form| %>
<%% if @assistant.errors.any? %>
<div class="error-messages">
<h2><%= pluralize(@assistant.errors.count, "error") %> prohibited this assistant from being saved:</h2>
<h2><%%= pluralize(@assistant.errors.count, "error") %> prohibited this assistant from being saved:</h2>
<ul>
<% @assistant.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
<%% @assistant.errors.full_messages.each do |message| %>
<li><%%= message %></li>
<%% end %>
</ul>
</div>
<% end %>
<%% end %>

<div class="form-group">
<%= form.label :instructions, "Instructions for the Assistant" %>
<%= form.text_area :instructions, rows: 5, placeholder: "Enter instructions for the assistant..." %>
<%%= form.label :instructions, "Instructions for the Assistant" %>
<%%= form.text_area :instructions, rows: 5, placeholder: "Enter instructions for the assistant..." %>
</div>

<div class="form-group">
<%%= form.label :tool_choice, "Tool Choice" %>
<%%= form.select :tool_choice, options_for_select([
['Auto', 'auto'],
['None', 'none'],
['Any', 'any']
]), {}, { class: 'tool-choice-select' } %>
</div>

<div class="form-actions">
<%= form.submit "Create Assistant", class: "submit-button" %>
<%= link_to 'Back to Assistants', assistants_path, class: "back-link" %>
<%%= form.submit "Create Assistant", class: "submit-button" %>
<%%= link_to 'Back to Assistants', assistants_path, class: "back-link" %>
</div>
<% end %>
</div>
<%% end %>
</div>
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<div class="chat-container">
<h1 class="chat-header">Assistant: <%= @assistant.id %></h1>
<h1 class="chat-header">Assistant: <%%= @assistant.id %></h1>

<div id="chat-messages" class="chat-messages">
<%= render partial: "assistants/message", collection: @messages %>
<%%= render partial: "assistants/message", collection: @messages %>
</div>

<%= turbo_frame_tag "new_message" do %>
<%= render "assistants/message_form" %>
<% end %>
<%%= turbo_frame_tag "new_message" do %>
<%%= render "assistants/message_form" %>
<%% end %>
</div>

0 comments on commit 05d4b12

Please sign in to comment.