Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix assistant creation #68

Merged
merged 5 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions app/controllers/base_assistants_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def index

# POST /assistants or /assistants.json
def create
json = JSON.parse(params[:json])
json = JSON.parse(params[:json]) if params[:json].present?
@assistant = Assistant.new(json || assistant_params)

authorize @assistant
Expand Down Expand Up @@ -58,6 +58,6 @@ def set_assistant

# Only allow a list of trusted parameters through.
def assistant_params
params.require(:assistant).permit(:libraries, :name, :input, :output, :context, :instructions, :description, :status, :quip_url, :confluence_spaces)
params.require(:assistant).permit(:libraries, :name, :input, :output, :context, :instructions, :description, :status, :quip_url, :confluence_spaces, :user_id)
end
end
2 changes: 0 additions & 2 deletions app/models/assistant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ class Assistant < ApplicationRecord
validates :libraries, presence: true

validates :input, presence: true
validates :instructions, presence: true
validates :output, presence: true

validate :libraries_must_be_csv_with_numbers

Expand Down
4 changes: 0 additions & 4 deletions app/views/assistants/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@
<%= form.label :context %>
<%= form.text_area :context, rows: 4, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
</div>
<div class="my-5">
<%= label_tag :json %>
<%= text_area_tag :json, nil, rows: 4, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
</div>
<div class="inline">
<%= form.submit "Save", class: "rounded-lg py-3 px-5 bg-sky-600 text-white inline-block font-medium cursor-pointer" %>
</div>
Expand Down
16 changes: 10 additions & 6 deletions app/views/assistants/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
<div class="w-full">
<% content_for :title, "Assistants" %>
<div class="flex justify-between items-center">
<%= render 'shared/page_header', title: 'Assistants', subtitle: 'Assistants have special instructions and context to answer specific problems better than general Q/A. Click "Chat" to begin!' %>
<% if policy(Assistant.new).edit? %>
<%= link_to "New +", new_assistant_path, class: "rounded-lg py-3 px-5 bg-sky-900 text-white block font-medium" %>
<%= link_to "Import", import_assistants_path, class: "rounded-lg py-3 px-5 bg-sky-900 text-white block font-medium" %>
<% end %>
</div>
<%= render 'shared/page_header', title: 'Assistants', subtitle: 'Assistants have special instructions and context to answer specific problems better than general Q/A. Click "Chat" to begin!' %>
<div>
<% if policy(Assistant.new).edit? %>
<div class="inline-flex rounded-md shadow-sm" role="group">
<%= link_to "New +", new_assistant_path, class: "border border-sky-600 border-r-0 py-3 px-5 bg-sky-100 text-sky-600 font-medium border border-sky-900 rounded-l-lg hover:bg-sky-700 hover:text-sky-100" %>
<%= link_to "Import", import_assistants_path, class: "border border-sky-600 py-3 px-5 bg-sky-100 text-sky-600 font-medium border border-sky-900 rounded-r-lg hover:bg-sky-700 hover:text-sky-100" %>
</div>
<% end %>
</div>
</div>
<div id="assistants" class="mt-5 space-y-4">
<% @assistants.each do |assistant| %>
<div class="flex justify-between items-center bg-white rounded-lg shadow-lg p-4 border-stone-200 border">
Expand Down
2 changes: 0 additions & 2 deletions spec/models/assistant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
describe 'validations' do
it { should validate_presence_of(:libraries) }
it { should validate_presence_of(:input) }
it { should validate_presence_of(:instructions) }
it { should validate_presence_of(:output) }

context 'libraries CSV validation' do
it 'is valid with a valid CSV string of numbers' do
Expand Down
Loading