Class: MagicQuery::Providers::OpenAI
- Defined in:
- lib/magic_query/providers/openai.rb
Constant Summary collapse
- API_URL =
'https://api.openai.com/v1/chat/completions'
Instance Attribute Summary
Attributes inherited from Base
#api_key, #max_tokens, #model, #temperature
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from MagicQuery::Providers::Base
Instance Method Details
#generate(prompt) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/magic_query/providers/openai.rb', line 11 def generate(prompt) response = http_client.post(API_URL) do |req| generate_headers.each { |key, value| req.headers[key] = value } req.body = generate_body(prompt) end handle_response(response) end |