Class: Durable::Llm::Providers::Anthropic::AnthropicMessage
- Inherits:
-
Object
- Object
- Durable::Llm::Providers::Anthropic::AnthropicMessage
- Defined in:
- lib/durable/llm/providers/anthropic.rb
Overview
Represents a message in an Anthropic conversation.
Messages have a role (user, assistant) and content composed of text blocks.
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
Instance Method Summary collapse
-
#initialize(response) ⇒ AnthropicMessage
constructor
A new instance of AnthropicMessage.
- #to_s ⇒ Object
Constructor Details
#initialize(response) ⇒ AnthropicMessage
Returns a new instance of AnthropicMessage.
309 310 311 312 |
# File 'lib/durable/llm/providers/anthropic.rb', line 309 def initialize(response) @role = response['role'] @content = response['content']&.map { |block| block['text'] }&.join(' ') || '' end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
307 308 309 |
# File 'lib/durable/llm/providers/anthropic.rb', line 307 def content @content end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
307 308 309 |
# File 'lib/durable/llm/providers/anthropic.rb', line 307 def role @role end |
Instance Method Details
#to_s ⇒ Object
314 315 316 |
# File 'lib/durable/llm/providers/anthropic.rb', line 314 def to_s @content end |