Skip to content

Commit

Permalink
Fix missing namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
CoralineAda committed Aug 28, 2024
1 parent fa55f57 commit 6e75874
Showing 1 changed file with 30 additions and 29 deletions.
59 changes: 30 additions & 29 deletions app/models/services/derive_themes.rb
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
class DeriveThemes
module Services
class DeriveThemes

attr_accessor :text
attr_accessor :text

# 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 20 most relevant themes from the following list of codes. The themes should be all lowercase and contain no punctuation. Codes should be stripped of quotation marks. Return each code with an array of its categories in JSON format. Use this JSON as the format:
# 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 20 most relevant themes from the following list of codes. The themes should be all lowercase and contain no punctuation. Codes should be stripped of quotation marks. Return each code with an array of its categories in JSON format. Use this JSON as the format:
{
"themes" : [
{
"theme": "foo",
"codes": [ "bar", "bat", "baz"]
}
]
}
The codes are as follows:
}
{
"themes" : [
{
"theme": "foo",
"codes": [ "bar", "bat", "baz"]
}
]
}
def self.perform(text)
new(text).perform
end
The codes are as follows:
}

def initialize(text)
@text = text
end
def self.perform(text)
new(text).perform
end

# Uses the OpenAI client to pass the prompt and text through the API for sentiment analysis.
def perform
return false unless text.present?
def initialize(text)
@text = text
end

response = Clients::OpenAi.request("#{PROMPT} #{self.text}")
return false unless response['themes'].present?
return response['themes']
end
# Uses the OpenAI client to pass the prompt and text through the API for sentiment analysis.
def perform
return false unless text.present?

response = Clients::OpenAi.request("#{PROMPT} #{self.text}")
return false unless response['themes'].present?
return response['themes']
end

end
end

0 comments on commit 6e75874

Please sign in to comment.