Class: LlamaHair::Client
- Inherits:
-
Object
- Object
- LlamaHair::Client
- Defined in:
- lib/llamahair/client.rb
Instance Attribute Summary collapse
-
#api_key_id ⇒ Object
readonly
Returns the value of attribute api_key_id.
-
#api_key_secret ⇒ Object
readonly
Returns the value of attribute api_key_secret.
Instance Method Summary collapse
-
#initialize(options) ⇒ Client
constructor
A new instance of Client.
-
#retrieve(request) ⇒ Types::LlamaResponse
Retrieve a response from the Llama API.
-
#send(prompt_url, request) ⇒ Types::SendResponse
Send a request to the Llama API.
-
#send_and_retrieve(prompt_url, request) ⇒ Types::LlamaResponse
Send a request and wait for the response.
Constructor Details
#initialize(options) ⇒ Client
Returns a new instance of Client.
8 9 10 11 |
# File 'lib/llamahair/client.rb', line 8 def initialize() @api_key_id = ENV['LLAMAHAIR_API_KEY_ID'] || .api_key_id @api_key_secret = ENV['LLAMAHAIR_API_SECRET'] || .api_key_secret end |
Instance Attribute Details
#api_key_id ⇒ Object (readonly)
Returns the value of attribute api_key_id.
5 6 7 |
# File 'lib/llamahair/client.rb', line 5 def api_key_id @api_key_id end |
#api_key_secret ⇒ Object (readonly)
Returns the value of attribute api_key_secret.
5 6 7 |
# File 'lib/llamahair/client.rb', line 5 def api_key_secret @api_key_secret end |
Instance Method Details
#retrieve(request) ⇒ Types::LlamaResponse
Retrieve a response from the Llama API
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/llamahair/client.rb', line 32 def retrieve(request) client = RetrieveClient.new( Types::RetrieveClientOptions.new( job_id: request.job_id, api_key_id: api_key_id, api_key_secret: api_key_secret ) ) client.retrieve(request) end |
#send(prompt_url, request) ⇒ Types::SendResponse
Send a request to the Llama API
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/llamahair/client.rb', line 17 def send(prompt_url, request) client = SendClient.new( Types::SendClientOptions.new( prompt_url: prompt_url, api_key_id: api_key_id, api_key_secret: api_key_secret ) ) client.send(request) end |
#send_and_retrieve(prompt_url, request) ⇒ Types::LlamaResponse
Send a request and wait for the response
48 49 50 51 |
# File 'lib/llamahair/client.rb', line 48 def send_and_retrieve(prompt_url, request) job_id_response = send(prompt_url, request) retrieve(job_id_response) end |