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.
-
#tool_calls ⇒ Array<Hash>?
readonly
The tool_calls attribute reader returns the tool call hashes or objects associated with the message.
-
#tool_name ⇒ String?
readonly
The tool_name attribute reader returns the name of the tool used in the message, if any.
Instance Method Summary collapse
-
#initialize(role:, content:, thinking: nil, images: nil, tool_calls: nil, tool_name: 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, tool_name: nil) ⇒ Message
The initialize method sets up a new Message instance with the specified attributes.
63 64 65 66 67 68 |
# File 'lib/ollama/message.rb', line 63 def initialize(role:, content:, thinking: nil, images: nil, tool_calls: nil, tool_name: nil, **) @role, @content, @thinking, @images, @tool_calls, @tool_name = role, content, thinking, (Array(images) if images), (Array(tool_calls) if tool_calls), tool_name 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 |
#tool_calls ⇒ Array<Hash>? (readonly)
The tool_calls attribute reader returns the tool call hashes or objects associated with the message.
48 49 50 |
# File 'lib/ollama/message.rb', line 48 def tool_calls @tool_calls end |
#tool_name ⇒ String? (readonly)
The tool_name attribute reader returns the name of the tool used in the message, if any.
54 55 56 |
# File 'lib/ollama/message.rb', line 54 def tool_name @tool_name end |