Skip to content

Commit

Permalink
Merge pull request #168 from identity-research-lab/category-suggestions
Browse files Browse the repository at this point in the history
HOTPATCH - restore temporary route for category suggestions
  • Loading branch information
CoralineAda authored Oct 30, 2024
2 parents 30d64ac + 11d8b53 commit d514368
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
13 changes: 8 additions & 5 deletions app/models/services/suggest_categories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@ class SuggestCategories

# This is the prompt sent to the selected AI agent to provide instructions on category derivision.
PROMPT = %{
You are a social researcher doing data analysis. Please generate a list of the most relevant categories from the following list of codes. The categories should be all lowercase and contain no punctuation. Return each category with an array of its applicable codes in JSON format.Do not remove any punctuation from the codes that are returned. Use this JSON as the output format:
You are a social researcher doing qualitative analysis on survey data. Please generate a list of suggested categories from a list of codes. The categories should be all lowercase and contain no punctuation. Use this JSON as the output format:
{
"categories" : [
{
"category": "foo",
"codes": [ "bar", "bat", "baz"]
}
"category": "foo"
},
{
"category": "bar"
},
]
}
The codes are provided in the following list:
The list of codes is:
}

def self.perform(text)
Expand Down
2 changes: 1 addition & 1 deletion app/models/survey_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class SurveyResponse < ApplicationRecord
has_one :annotation, dependent: :destroy
has_many :responses, dependent: :destroy

# This should only be called as part of an asynchronous job
# This should normally only be called as part of an asynchronous job.
def self.from(record_id, record)
if survey_response = SurveyResponse.find_or_create_by(response_id: record_id)
Question.all.each do |question|
Expand Down
5 changes: 4 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@
get "about", controller: "static", action: "about"

resources :annotations
resources :codebooks
resources :responses
resources :stats
resources :themes

resources :codebooks do
post "enqueue_categories", action: "enqueue_categories"
end

resources :questions do
resources :categories
end
Expand Down

0 comments on commit d514368

Please sign in to comment.