Sha256: f97f73ae93c6ab25e4fec5953309716c0f97f240bb816d22d58b3a894ffb9f7f

Contents?: true

Size: 789 Bytes

Versions: 1

Compression:

Stored size: 789 Bytes

Contents

# frozen_string_literal: true

# add path to ruby-spacy lib to load path
$LOAD_PATH.unshift(File.expand_path("../../lib", __dir__))

require "ruby-spacy"

api_key = ENV["OPENAI_API_KEY"]
nlp = Spacy::Language.new("en_core_web_sm")
doc = nlp.read("The Beatles released 12 studio albums")

# default parameter values
# max_tokens: 1000
# temperature: 0.7
# model: "gpt-3.5-turbo-0613"
res = doc.openai_query(
  access_token: api_key,
  model: "gpt-4",
  prompt: "Generate a tree diagram from the text in the following style: [S [NP [Det the] [N cat]] [VP [V sat] [PP [P on] [NP the mat]]]"
)

puts res

# [S
#   [NP
#     [Det The]
#     [N Beatles]
#   ]
#   [VP
#     [V released]
#     [NP
#       [Num 12]
#       [N
#         [N studio]
#         [N albums]
#       ]
#     ]
#   ]
# ]

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-spacy-0.2.2 examples/openai_integration/openai_query_4.rb