Class: RubynCode::LLM::Response

Inherits:
Data
  • Object
show all
Defined in:
lib/rubyn_code/llm/message_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, content:, stop_reason:, usage:, stop_details: nil) ⇒ Response

Returns a new instance of Response.



36
37
38
# File 'lib/rubyn_code/llm/message_builder.rb', line 36

def initialize(id:, content:, stop_reason:, usage:, stop_details: nil)
  super
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content

Returns:

  • (Object)

    the current value of content



35
36
37
# File 'lib/rubyn_code/llm/message_builder.rb', line 35

def content
  @content
end

#idObject (readonly)

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



35
36
37
# File 'lib/rubyn_code/llm/message_builder.rb', line 35

def id
  @id
end

#stop_detailsObject (readonly)

Returns the value of attribute stop_details

Returns:

  • (Object)

    the current value of stop_details



35
36
37
# File 'lib/rubyn_code/llm/message_builder.rb', line 35

def stop_details
  @stop_details
end

#stop_reasonObject (readonly)

Returns the value of attribute stop_reason

Returns:

  • (Object)

    the current value of stop_reason



35
36
37
# File 'lib/rubyn_code/llm/message_builder.rb', line 35

def stop_reason
  @stop_reason
end

#usageObject (readonly)

Returns the value of attribute usage

Returns:

  • (Object)

    the current value of usage



35
36
37
# File 'lib/rubyn_code/llm/message_builder.rb', line 35

def usage
  @usage
end

Instance Method Details

#refusal?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/rubyn_code/llm/message_builder.rb', line 52

def refusal?
  stop_reason == 'refusal'
end

#textObject



40
41
42
# File 'lib/rubyn_code/llm/message_builder.rb', line 40

def text
  content.select { |b| b.type == 'text' }.map(&:text).join
end

#tool_callsObject



44
45
46
# File 'lib/rubyn_code/llm/message_builder.rb', line 44

def tool_calls
  content.select { |b| b.type == 'tool_use' }
end

#tool_use?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/rubyn_code/llm/message_builder.rb', line 48

def tool_use?
  stop_reason == 'tool_use'
end