Skip to content

Commit

Permalink
Rename user.prompt to user.system_prompt
Browse files Browse the repository at this point in the history
be clearer that there is a system prompt and a seperate "user prompt" that is generated at run time.
  • Loading branch information
epugh committed Jan 15, 2025
1 parent e935723 commit 12802ca
Show file tree
Hide file tree
Showing 18 changed files with 24 additions and 28 deletions.
2 changes: 1 addition & 1 deletion app/controllers/ai_judges/prompts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def update

# Only allow a list of trusted parameters through.
def ai_judge_params
params.expect(user: [ :openai_key, :prompt ])
params.expect(user: [ :openai_key, :system_prompt ])
end

def query_doc_pair_params
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/ai_judges_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class AiJudgesController < ApplicationController

def new
@ai_judge = User.new
@ai_judge.prompt = DEFAULT_SYSTEM_PROMPT
@ai_judge.system_prompt = DEFAULT_SYSTEM_PROMPT
end

def edit
Expand Down Expand Up @@ -103,6 +103,6 @@ def set_team

# Only allow a list of trusted parameters through.
def ai_judge_params
params.expect(user: [ :name, :openai_key, :prompt ])
params.expect(user: [ :name, :openai_key, :system_prompt ])
end
end
2 changes: 1 addition & 1 deletion app/models/api_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Table name: api_keys
#
# id :bigint not null, primary key
# token_digest :string(255)
# token_digest :string(255) not null
# created_at :datetime not null
# updated_at :datetime not null
# user_id :integer
Expand Down
1 change: 0 additions & 1 deletion app/models/case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#
# Indexes
#
# idx_cases_owner_id (owner_id)
# idx_owner_archived (owner_id,archived)
# index_cases_book_id (book_id)
# user_id (owner_id)
Expand Down
2 changes: 0 additions & 2 deletions app/models/score.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
#
# case_id (case_id)
# index_case_scores_annotation_id (annotation_id) UNIQUE
# index_case_scores_on_try_id (try_id)
# support_last_score (updated_at,created_at,id)
# try_id (try_id)
# user_id (user_id)
#
# Foreign Keys
Expand Down
4 changes: 2 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# agreed :boolean
# agreed_time :datetime
# company :string(255)
# completed_case_wizard :integer default(0), unsigned, not null
# completed_case_wizard :boolean default(FALSE), not null
# email :string(80)
# email_marketing :boolean default(FALSE), not null
# invitation_accepted_at :datetime
Expand All @@ -27,10 +27,10 @@
# openai_key :string(255)
# password :string(120)
# profile_pic :string(4000)
# prompt :string(4000)
# reset_password_sent_at :datetime
# reset_password_token :string(255)
# stored_raw_invitation_token :string(255)
# system_prompt :string(4000)
# created_at :datetime not null
# updated_at :datetime not null
# default_scorer_id :integer
Expand Down
2 changes: 1 addition & 1 deletion app/services/llm_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def initialize openai_key, _opts = {}

def make_judgement judge, query_doc_pair
user_prompt = make_user_prompt query_doc_pair
results = get_llm_response user_prompt, judge.prompt
results = get_llm_response user_prompt, judge.system_prompt
puts 'Here are the results'
puts results
judgement = Judgement.new(query_doc_pair: query_doc_pair, user: judge)
Expand Down
4 changes: 2 additions & 2 deletions app/views/ai_judges/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
</div>

<div class="row mb-3">
<%= form.label :prompt, class: 'col-sm-2 col-form-label' %>
<%= form.textarea :prompt, class: "form-control", rows: 6 %>
<%= form.label :system_prompt, class: 'col-sm-2 col-form-label' %>
<%= form.textarea :system_prompt, class: "form-control", rows: 6 %>
</div>
</div>

Expand Down
4 changes: 2 additions & 2 deletions app/views/ai_judges/prompts/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
</div>

<div>
<%= form.label :prompt, style: "display: block" %>
<%= form.textarea :prompt, class: "form-control", rows: 10 %>
<%= form.label :system_prompt, style: "display: block" %>
<%= form.textarea :system_prompt, class: "form-control", rows: 10 %>
</div>

<div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RenamePromptToSystemPromptForUser < ActiveRecord::Migration[8.0]
def change
rename_column :users, :prompt, :system_prompt
end
end
4 changes: 2 additions & 2 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/controllers/ai_judges_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class AiJudgesControllerTest < ActionDispatch::IntegrationTest
assert_difference('User.count') do
post team_ai_judges_url(team_id: team.id),
params: { user: { email: "#{ai_judge.email}-1", name: ai_judge.name, openai_key: ai_judge.openai_key,
prompt: ai_judge.prompt } }
system_prompt: ai_judge.system_prompt } }
end
assert_redirected_to teams_core_url(id: team.id)
end
Expand Down
1 change: 0 additions & 1 deletion test/fixtures/cases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#
# Indexes
#
# idx_cases_owner_id (owner_id)
# idx_owner_archived (owner_id,archived)
# index_cases_book_id (book_id)
# user_id (owner_id)
Expand Down
2 changes: 0 additions & 2 deletions test/fixtures/scores.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
#
# case_id (case_id)
# index_case_scores_annotation_id (annotation_id) UNIQUE
# index_case_scores_on_try_id (try_id)
# support_last_score (updated_at,created_at,id)
# try_id (try_id)
# user_id (user_id)
#
# Foreign Keys
Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# agreed :boolean
# agreed_time :datetime
# company :string(255)
# completed_case_wizard :integer default(0), unsigned, not null
# completed_case_wizard :boolean default(FALSE), not null
# email :string(80)
# email_marketing :boolean default(FALSE), not null
# invitation_accepted_at :datetime
Expand All @@ -23,10 +23,10 @@
# openai_key :string(255)
# password :string(120)
# profile_pic :string(4000)
# prompt :string(4000)
# reset_password_sent_at :datetime
# reset_password_token :string(255)
# stored_raw_invitation_token :string(255)
# system_prompt :string(4000)
# created_at :datetime not null
# updated_at :datetime not null
# default_scorer_id :integer
Expand Down Expand Up @@ -219,4 +219,4 @@ admin:
judge_judy:
password: $2a$12$Yf6zIiRvsHWDrhBxN0trXe/b/TTTSE3nK736Qbz2bGsowrjn3n2xC
openai_key: 1234asdf5678
prompt: You are a grocery store shopper. You like cheese. Is this a cheese?
system_prompt: You are a grocery store shopper. You like cheese. Is this a cheese?
1 change: 0 additions & 1 deletion test/models/case_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#
# Indexes
#
# idx_cases_owner_id (owner_id)
# idx_owner_archived (owner_id,archived)
# index_cases_book_id (book_id)
# user_id (owner_id)
Expand Down
2 changes: 0 additions & 2 deletions test/models/score_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
#
# case_id (case_id)
# index_case_scores_annotation_id (annotation_id) UNIQUE
# index_case_scores_on_try_id (try_id)
# support_last_score (updated_at,created_at,id)
# try_id (try_id)
# user_id (user_id)
#
# Foreign Keys
Expand Down
4 changes: 2 additions & 2 deletions test/models/user_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# agreed :boolean
# agreed_time :datetime
# company :string(255)
# completed_case_wizard :integer default(0), unsigned, not null
# completed_case_wizard :boolean default(FALSE), not null
# email :string(80)
# email_marketing :boolean default(FALSE), not null
# invitation_accepted_at :datetime
Expand All @@ -27,10 +27,10 @@
# openai_key :string(255)
# password :string(120)
# profile_pic :string(4000)
# prompt :string(4000)
# reset_password_sent_at :datetime
# reset_password_token :string(255)
# stored_raw_invitation_token :string(255)
# system_prompt :string(4000)
# created_at :datetime not null
# updated_at :datetime not null
# default_scorer_id :integer
Expand Down

0 comments on commit 12802ca

Please sign in to comment.