From 9ea568eede5df183acbb4df1a1bdd197f98957d2 Mon Sep 17 00:00:00 2001 From: Vijay Swamidass Date: Thu, 3 Oct 2024 16:10:33 -0700 Subject: [PATCH 1/3] simplify assistant creation --- app/controllers/base_assistants_controller.rb | 4 ++-- app/models/assistant.rb | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/controllers/base_assistants_controller.rb b/app/controllers/base_assistants_controller.rb index ae29fd9..729eb63 100644 --- a/app/controllers/base_assistants_controller.rb +++ b/app/controllers/base_assistants_controller.rb @@ -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 @@ -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 diff --git a/app/models/assistant.rb b/app/models/assistant.rb index 688afb5..3dfb4e2 100644 --- a/app/models/assistant.rb +++ b/app/models/assistant.rb @@ -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 From a15a37cd935380a381028a280772dadfab75646f Mon Sep 17 00:00:00 2001 From: Vijay Swamidass Date: Thu, 3 Oct 2024 16:26:10 -0700 Subject: [PATCH 2/3] adjust assistant form --- app/views/assistants/_form.html.erb | 4 ---- app/views/assistants/index.html.erb | 16 ++++++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/views/assistants/_form.html.erb b/app/views/assistants/_form.html.erb index ca3a88d..302c828 100644 --- a/app/views/assistants/_form.html.erb +++ b/app/views/assistants/_form.html.erb @@ -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" %> -
- <%= 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" %> -
<%= form.submit "Save", class: "rounded-lg py-3 px-5 bg-sky-600 text-white inline-block font-medium cursor-pointer" %>
diff --git a/app/views/assistants/index.html.erb b/app/views/assistants/index.html.erb index fc77b86..efd96d2 100644 --- a/app/views/assistants/index.html.erb +++ b/app/views/assistants/index.html.erb @@ -1,12 +1,16 @@
<% content_for :title, "Assistants" %>
- <%= 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 %> -
+ <%= 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: "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" %> +
+ <% end %> +
+
<% @assistants.each do |assistant| %>
From 50d2ef0ffb6aa446c309be3466490221ccfa2187 Mon Sep 17 00:00:00 2001 From: Vijay Swamidass Date: Thu, 3 Oct 2024 17:54:26 -0700 Subject: [PATCH 3/3] tests --- spec/models/assistant_spec.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/spec/models/assistant_spec.rb b/spec/models/assistant_spec.rb index 2f773d9..5c74f40 100644 --- a/spec/models/assistant_spec.rb +++ b/spec/models/assistant_spec.rb @@ -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