Class: Prescient::Agent::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/prescient/agent/result.rb

Overview

Immutable summary of one agent run.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response:, provider:, model:, loops_run:, success: true, metadata: {}) ⇒ Result

Returns a new instance of Result.



9
10
11
12
13
14
15
16
# File 'lib/prescient/agent/result.rb', line 9

def initialize(response:, provider:, model:, loops_run:, success: true, metadata: {})
  @response = response
  @provider = provider
  @model = model
  @loops_run = loops_run
  @success = success
  @metadata = 
end

Instance Attribute Details

#loops_runObject (readonly)

Returns the value of attribute loops_run.



7
8
9
# File 'lib/prescient/agent/result.rb', line 7

def loops_run
  @loops_run
end

#metadataObject (readonly)

Returns the value of attribute metadata.



7
8
9
# File 'lib/prescient/agent/result.rb', line 7

def 
  @metadata
end

#modelObject (readonly)

Returns the value of attribute model.



7
8
9
# File 'lib/prescient/agent/result.rb', line 7

def model
  @model
end

#providerObject (readonly)

Returns the value of attribute provider.



7
8
9
# File 'lib/prescient/agent/result.rb', line 7

def provider
  @provider
end

#responseObject (readonly)

Returns the value of attribute response.



7
8
9
# File 'lib/prescient/agent/result.rb', line 7

def response
  @response
end

Instance Method Details

#success?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/prescient/agent/result.rb', line 18

def success?
  @success
end

#to_hHash

Serialize the result into a safe structured response.

Returns:

  • (Hash)

    Result data



24
25
26
27
28
29
30
31
32
33
# File 'lib/prescient/agent/result.rb', line 24

def to_h
  {
    response: @response,
    provider: @provider,
    model: @model,
    loops_run: @loops_run,
    success: success?,
    metadata: @metadata
  }
end