Class: Crimson::Message::User

Inherits:
Base
  • Object
show all
Defined in:
lib/crimson/message.rb

Overview

A user message.

Instance Attribute Summary collapse

Attributes inherited from Base

#role

Instance Method Summary collapse

Constructor Details

#initialize(content) ⇒ User

Returns a new instance of User.

Parameters:

  • content (String)


48
49
50
51
# File 'lib/crimson/message.rb', line 48

def initialize(content)
  super("user")
  @content = content
end

Instance Attribute Details

#contentString (readonly)

Returns the user message content.

Returns:

  • (String)

    the user message content



45
46
47
# File 'lib/crimson/message.rb', line 45

def content
  @content
end

Instance Method Details

#to_anthropic_hHash

Returns Anthropic-compatible representation.

Returns:

  • (Hash)

    Anthropic-compatible representation



59
60
61
# File 'lib/crimson/message.rb', line 59

def to_anthropic_h
  { role: "user", content: @content }
end

#to_openai_hHash

Returns OpenAI-compatible representation.

Returns:

  • (Hash)

    OpenAI-compatible representation



54
55
56
# File 'lib/crimson/message.rb', line 54

def to_openai_h
  { role: "user", content: @content }
end