Sha256: ddbfe81f2fb9d4f15dac12ac986b939c7815b8cf2c5f94d9c2008170f579814c
Contents?: true
Size: 549 Bytes
Versions: 1
Compression:
Stored size: 549 Bytes
Contents
# frozen_string_literal: true module QuickOpenAI module Gpt3 def self.gpt3(prompt, **options) parameters = { model: "gpt-3.5-turbo-instruct", max_tokens: 2048, prompt: prompt, **options } response = QuickOpenAI.fetch_response_from_client do |client| client.completions(parameters: parameters) end text = response.dig("choices", 0, "text") raise QuickOpenAI::Error, "Unable to parse response." if text.nil? || text.empty? text.chomp.strip end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
quick_openai-0.1.3 | lib/quick_openai/gpt3.rb |