Skip to content

Commit

Permalink
Upgrade and refactor OpenAI client for #4058
Browse files Browse the repository at this point in the history
  • Loading branch information
benwbrum committed Apr 24, 2024
1 parent 3598ab0 commit bb55711
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ GEM
rspec-support (~> 3.12)
rspec-support (3.13.1)
rtl (0.6.0)
ruby-openai (6.3.1)
ruby-openai (6.5.0)
event_stream_parser (>= 0.3.0, < 2.0.0)
faraday (>= 1)
faraday-multipart (>= 1)
Expand Down
11 changes: 7 additions & 4 deletions lib/openai/description_tagger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ module DescriptionTagger
def self.tag_description_by_subject(description, tags, title="")
client = OpenAI::Client.new
prompt = prompt_by_subject(description, tags, title)
response = client.completions(
response = client.chat(
parameters: {
model: "gpt-3.5-turbo-instruct",
prompt: prompt,
model: "gpt-3.5-turbo-16k",
messages: [
{role: "system", content: "You are a metadata librarian with experience classifying documents by subject."},
{role: "user", content: prompt}
],
max_tokens: 100,
n: 1,
temperature: 0.0,
Expand All @@ -21,7 +24,7 @@ def self.tag_description_by_subject(description, tags, title="")
return []
end

raw_text = response['choices'].first['text']
raw_text = response['choices'].first['message']['content']

response_tags = []
print raw_text
Expand Down

0 comments on commit bb55711

Please sign in to comment.