Class: Riffer::Messages::Assistant

Inherits:
Base
  • Object
show all
Defined in:
lib/riffer/messages/assistant.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#content

Instance Method Summary collapse

Constructor Details

#initialize(content, tool_calls: []) ⇒ Assistant

Returns a new instance of Assistant.



6
7
8
9
# File 'lib/riffer/messages/assistant.rb', line 6

def initialize(content, tool_calls: [])
  super(content)
  @tool_calls = tool_calls
end

Instance Attribute Details

#tool_callsObject (readonly)

Returns the value of attribute tool_calls.



4
5
6
# File 'lib/riffer/messages/assistant.rb', line 4

def tool_calls
  @tool_calls
end

Instance Method Details

#roleObject



11
12
13
# File 'lib/riffer/messages/assistant.rb', line 11

def role
  "assistant"
end

#to_hObject



15
16
17
18
19
# File 'lib/riffer/messages/assistant.rb', line 15

def to_h
  hash = {role: role, content: content}
  hash[:tool_calls] = tool_calls unless tool_calls.empty?
  hash
end