Class: LlmGateway::BaseClient

Inherits:
Object
  • Object
show all
Defined in:
lib/llm_gateway/base_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model_key:, api_key:) ⇒ BaseClient

Returns a new instance of BaseClient.



11
12
13
14
# File 'lib/llm_gateway/base_client.rb', line 11

def initialize(model_key:, api_key:)
  @model_key = model_key
  @api_key = api_key
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



9
10
11
# File 'lib/llm_gateway/base_client.rb', line 9

def api_key
  @api_key
end

#base_endpointObject (readonly)

Returns the value of attribute base_endpoint.



9
10
11
# File 'lib/llm_gateway/base_client.rb', line 9

def base_endpoint
  @base_endpoint
end

#model_keyObject (readonly)

Returns the value of attribute model_key.



9
10
11
# File 'lib/llm_gateway/base_client.rb', line 9

def model_key
  @model_key
end

Instance Method Details

#get(url_part, extra_headers = {}) ⇒ Object



16
17
18
19
20
# File 'lib/llm_gateway/base_client.rb', line 16

def get(url_part, extra_headers = {})
  endpoint = "#{base_endpoint}/#{url_part.sub(%r{^/}, "")}"
  response = make_request(endpoint, Net::HTTP::Get, nil, extra_headers)
  process_response(response)
end

#post(url_part, body = nil, extra_headers = {}) ⇒ Object



22
23
24
25
26
# File 'lib/llm_gateway/base_client.rb', line 22

def post(url_part, body = nil, extra_headers = {})
  endpoint = "#{base_endpoint}/#{url_part.sub(%r{^/}, "")}"
  response = make_request(endpoint, Net::HTTP::Post, body, extra_headers)
  process_response(response)
end