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.



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

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

Instance Method Details

#contentObject



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

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

#imagesObject



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

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

#roleObject



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

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

#thinkingObject



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

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

#to_hObject



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

def to_h
  @data
end

#tool_callsObject



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

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

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