Class: Ollama::Message
Overview
Ollama::Message
Represents a message object used in communication with the Ollama API. This class encapsulates the essential components of a message, including the role of the sender, the content of the message, optional thinking content, associated images, and tool calls.
Instance Attribute Summary collapse
- 
  
    
      #content  ⇒ String 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    The content attribute reader returns the textual content of the message. 
- 
  
    
      #images  ⇒ Array<Ollama::Image>? 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    The images attribute reader returns the image objects associated with the message. 
- 
  
    
      #role  ⇒ String 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    The role attribute reader returns the role associated with the message. 
- 
  
    
      #thinking  ⇒ String? 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    The thinking attribute reader returns the thinking content associated with the message. 
Instance Method Summary collapse
- 
  
    
      #initialize(role:, content:, thinking: nil, images: nil, tool_calls: nil)  ⇒ Message 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    The initialize method sets up a new Message instance with the specified attributes. 
Methods included from DTO
#==, #as_array, #as_array_of_hashes, #as_hash, #as_json, #empty?, #to_json
Constructor Details
#initialize(role:, content:, thinking: nil, images: nil, tool_calls: nil) ⇒ Message
The initialize method sets up a new Message instance with the specified attributes.
| 51 52 53 54 55 | # File 'lib/ollama/message.rb', line 51 def initialize(role:, content:, thinking: nil, images: nil, tool_calls: nil, **) @role, @content, @thinking, @images, @tool_calls = role, content, thinking, (Array(images) if images), (Array(tool_calls) if tool_calls) end | 
Instance Attribute Details
#content ⇒ String (readonly)
The content attribute reader returns the textual content of the message.
| 32 33 34 | # File 'lib/ollama/message.rb', line 32 def content @content end | 
#images ⇒ Array<Ollama::Image>? (readonly)
The images attribute reader returns the image objects associated with the message.
| 42 43 44 | # File 'lib/ollama/message.rb', line 42 def images @images end | 
#role ⇒ String (readonly)
The role attribute reader returns the role associated with the message.
| 27 28 29 | # File 'lib/ollama/message.rb', line 27 def role @role end | 
#thinking ⇒ String? (readonly)
The thinking attribute reader returns the thinking content associated with the message.
| 37 38 39 | # File 'lib/ollama/message.rb', line 37 def thinking @thinking end |