Class: LittleGhost::ModelResponse

Inherits:
Data
  • Object
show all
Defined in:
lib/little_ghost/model_response.rb,
lib/little_ghost/model_response.rb

Overview

Represents the final result shared by every provider stream. It keeps provider-specific response shapes out of the agent loop.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message:, stop_reason:, usage: Usage.new, metadata: {}) ⇒ ModelResponse

Creates an immutable response and coerces message into a Message.



11
12
13
14
15
16
17
18
# File 'lib/little_ghost/model_response.rb', line 11

def initialize(message:, stop_reason:, usage: Usage.new, metadata: {})
  super(
    message: Message.coerce(message),
    stop_reason: stop_reason&.to_sym,
    usage: usage,
    metadata: .freeze
  )
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message

Returns:

  • (Object)

    the current value of message



9
10
11
# File 'lib/little_ghost/model_response.rb', line 9

def message
  @message
end

#metadataObject (readonly)

Returns the value of attribute metadata

Returns:

  • (Object)

    the current value of metadata



9
10
11
# File 'lib/little_ghost/model_response.rb', line 9

def 
  @metadata
end

#stop_reasonObject (readonly)

Returns the value of attribute stop_reason

Returns:

  • (Object)

    the current value of stop_reason



9
10
11
# File 'lib/little_ghost/model_response.rb', line 9

def stop_reason
  @stop_reason
end

#usageObject (readonly)

Returns the value of attribute usage

Returns:

  • (Object)

    the current value of usage



9
10
11
# File 'lib/little_ghost/model_response.rb', line 9

def usage
  @usage
end