Class: Exa::Resources::AgentRun
- Inherits:
-
Struct
- Object
- Struct
- Exa::Resources::AgentRun
- Defined in:
- lib/exa/resources/agent_run.rb
Instance Attribute Summary collapse
-
#completed_at ⇒ Object
Returns the value of attribute completed_at.
-
#cost_dollars ⇒ Object
Returns the value of attribute cost_dollars.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#id ⇒ Object
Returns the value of attribute id.
-
#object ⇒ Object
Returns the value of attribute object.
-
#output ⇒ Object
Returns the value of attribute output.
-
#request ⇒ Object
Returns the value of attribute request.
-
#status ⇒ Object
Returns the value of attribute status.
-
#stop_reason ⇒ Object
Returns the value of attribute stop_reason.
-
#usage ⇒ Object
Returns the value of attribute usage.
Class Method Summary collapse
-
.from_response(body) ⇒ Object
Build from a raw API response body (camelCase keys), e.g.
Instance Method Summary collapse
- #cancelled? ⇒ Boolean
- #completed? ⇒ Boolean
- #failed? ⇒ Boolean
- #finished? ⇒ Boolean
-
#initialize(id:, object:, status:, stop_reason: nil, created_at: nil, completed_at: nil, request: nil, output: nil, usage: nil, cost_dollars: nil) ⇒ AgentRun
constructor
A new instance of AgentRun.
- #queued? ⇒ Boolean
- #running? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(id:, object:, status:, stop_reason: nil, created_at: nil, completed_at: nil, request: nil, output: nil, usage: nil, cost_dollars: nil) ⇒ AgentRun
Returns a new instance of AgentRun.
7 8 9 10 |
# File 'lib/exa/resources/agent_run.rb', line 7 def initialize(id:, object:, status:, stop_reason: nil, created_at: nil, completed_at: nil, request: nil, output: nil, usage: nil, cost_dollars: nil) super freeze end |
Instance Attribute Details
#completed_at ⇒ Object
Returns the value of attribute completed_at
3 4 5 |
# File 'lib/exa/resources/agent_run.rb', line 3 def completed_at @completed_at end |
#cost_dollars ⇒ Object
Returns the value of attribute cost_dollars
3 4 5 |
# File 'lib/exa/resources/agent_run.rb', line 3 def cost_dollars @cost_dollars end |
#created_at ⇒ Object
Returns the value of attribute created_at
3 4 5 |
# File 'lib/exa/resources/agent_run.rb', line 3 def created_at @created_at end |
#id ⇒ Object
Returns the value of attribute id
3 4 5 |
# File 'lib/exa/resources/agent_run.rb', line 3 def id @id end |
#object ⇒ Object
Returns the value of attribute object
3 4 5 |
# File 'lib/exa/resources/agent_run.rb', line 3 def object @object end |
#output ⇒ Object
Returns the value of attribute output
3 4 5 |
# File 'lib/exa/resources/agent_run.rb', line 3 def output @output end |
#request ⇒ Object
Returns the value of attribute request
3 4 5 |
# File 'lib/exa/resources/agent_run.rb', line 3 def request @request end |
#status ⇒ Object
Returns the value of attribute status
3 4 5 |
# File 'lib/exa/resources/agent_run.rb', line 3 def status @status end |
#stop_reason ⇒ Object
Returns the value of attribute stop_reason
3 4 5 |
# File 'lib/exa/resources/agent_run.rb', line 3 def stop_reason @stop_reason end |
#usage ⇒ Object
Returns the value of attribute usage
3 4 5 |
# File 'lib/exa/resources/agent_run.rb', line 3 def usage @usage end |
Class Method Details
.from_response(body) ⇒ Object
Build from a raw API response body (camelCase keys), e.g. a GET payload or the data of a terminal agent_run.* stream event.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/exa/resources/agent_run.rb', line 14 def self.from_response(body) new( id: body["id"], object: body["object"] || "agent_run", status: body["status"], stop_reason: body["stopReason"], created_at: body["createdAt"], completed_at: body["completedAt"], request: body["request"], output: body["output"], usage: body["usage"], cost_dollars: body["costDollars"] ) end |
Instance Method Details
#cancelled? ⇒ Boolean
33 |
# File 'lib/exa/resources/agent_run.rb', line 33 def cancelled? = status == 'cancelled' |
#completed? ⇒ Boolean
31 |
# File 'lib/exa/resources/agent_run.rb', line 31 def completed? = status == 'completed' |
#failed? ⇒ Boolean
32 |
# File 'lib/exa/resources/agent_run.rb', line 32 def failed? = status == 'failed' |
#finished? ⇒ Boolean
35 |
# File 'lib/exa/resources/agent_run.rb', line 35 def finished? = completed? || failed? || cancelled? |
#queued? ⇒ Boolean
29 |
# File 'lib/exa/resources/agent_run.rb', line 29 def queued? = status == 'queued' |
#running? ⇒ Boolean
30 |
# File 'lib/exa/resources/agent_run.rb', line 30 def running? = status == 'running' |
#to_h ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/exa/resources/agent_run.rb', line 37 def to_h result = { id: id, object: object, status: status } result[:stop_reason] = stop_reason if stop_reason result[:created_at] = created_at if created_at result[:completed_at] = completed_at if completed_at result[:request] = request if request result[:output] = output if output result[:usage] = usage if usage result[:cost_dollars] = cost_dollars if cost_dollars result end |