Class: RobotLab::TextMessage

Inherits:
Message
  • Object
show all
Defined in:
lib/robot_lab/message.rb

Overview

Text message from system, user, or assistant

Examples:

System message

TextMessage.new(role: :system, content: "You are a helpful assistant")

User message

TextMessage.new(role: :user, content: "Hello!")

Assistant response

TextMessage.new(role: :assistant, content: "Hi there!", stop_reason: :stop)

Constant Summary

Constants inherited from Message

Message::VALID_ROLES, Message::VALID_STOP_REASONS, Message::VALID_TYPES

Instance Attribute Summary

Attributes inherited from Message

#content, #role, #stop_reason, #type

Instance Method Summary collapse

Methods inherited from Message

#assistant?, from_hash, #stopped?, #system?, #text?, #to_h, #to_json, #tool_call?, #tool_result?, #tool_stop?, #user?

Constructor Details

#initialize(role:, content:, stop_reason: nil) ⇒ TextMessage

Creates a new TextMessage instance.

Parameters:

  • role (String, Symbol)

    the message role (system, user, or assistant)

  • content (String)

    the text content

  • stop_reason (String, Symbol, nil) (defaults to: nil)

    the stop reason



153
154
155
# File 'lib/robot_lab/message.rb', line 153

def initialize(role:, content:, stop_reason: nil)
  super(type: "text", role: role, content: content, stop_reason: stop_reason)
end