Class: OpenaiAssistant::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/openai_assistant/base.rb

Overview

Base class of openai

Instance Method Summary collapse

Constructor Details

#initialize(api_key = "") ⇒ Base

Returns a new instance of Base.



6
7
8
9
10
11
12
# File 'lib/openai_assistant/base.rb', line 6

def initialize(api_key = "")
  @openai_api_key = api_key
  # hard the host because if the official docs change the host, maybe it will change another
  # we need to update this gem for any change
  @openai_url = "https://api.openai.com/v1/assistants"
  @http_client = OpenaiAssistant::HTTPClient.new
end

Instance Method Details

#default_headersObject



14
15
16
17
18
19
20
# File 'lib/openai_assistant/base.rb', line 14

def default_headers
  {
    "Authorization": "Bearer #{@openai_api_key}",
    "OpenAI-Beta": "assistants=v1",
    "Content-Type": "application/json"
  }
end