Class: LlmGateway::BaseClient
- Inherits:
-
Object
- Object
- LlmGateway::BaseClient
- Defined in:
- lib/llm_gateway/base_client.rb
Direct Known Subclasses
Adapters::Claude::Client, Adapters::Groq::Client, Adapters::OpenAi::Client
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#base_endpoint ⇒ Object
readonly
Returns the value of attribute base_endpoint.
-
#model_key ⇒ Object
readonly
Returns the value of attribute model_key.
Instance Method Summary collapse
- #get(url_part, extra_headers = {}) ⇒ Object
-
#initialize(model_key:, api_key:) ⇒ BaseClient
constructor
A new instance of BaseClient.
- #post(url_part, body = nil, extra_headers = {}) ⇒ Object
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_key ⇒ Object (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_endpoint ⇒ Object (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_key ⇒ Object (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 |