Class: Durable::Llm::Providers::Anthropic::AnthropicMessage

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#contentObject (readonly)

Returns the value of attribute content.



307
308
309
# File 'lib/durable/llm/providers/anthropic.rb', line 307

def content
  @content
end

#roleObject (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_sObject



314
315
316
# File 'lib/durable/llm/providers/anthropic.rb', line 314

def to_s
  @content
end