Class: Ollama::Response::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/ollama/response.rb

Overview

Message wrapper for accessing message fields

Defined Under Namespace

Classes: ToolCall

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Message

Returns a new instance of Message.



133
134
135
# File 'lib/ollama/response.rb', line 133

def initialize(data)
  @data = data || {}
end

Instance Method Details

#contentObject



137
138
139
# File 'lib/ollama/response.rb', line 137

def content
  @data["content"] || @data[:content]
end

#imagesObject



156
157
158
# File 'lib/ollama/response.rb', line 156

def images
  @data["images"] || @data[:images]
end

#roleObject



152
153
154
# File 'lib/ollama/response.rb', line 152

def role
  @data["role"] || @data[:role]
end

#thinkingObject



141
142
143
# File 'lib/ollama/response.rb', line 141

def thinking
  @data["thinking"] || @data[:thinking]
end

#to_hObject



160
161
162
# File 'lib/ollama/response.rb', line 160

def to_h
  @data
end

#tool_callsObject



145
146
147
148
149
150
# File 'lib/ollama/response.rb', line 145

def tool_calls
  calls = @data["tool_calls"] || @data[:tool_calls]
  return [] unless calls

  calls.map { |call| ToolCall.new(call) }
end