Class: Conductor::Workflow::Llm::ChatMessage
- Inherits:
-
Object
- Object
- Conductor::Workflow::Llm::ChatMessage
- Defined in:
- lib/conductor/workflow/llm/chat_message.rb
Overview
ChatMessage represents a single message in an LLM chat conversation
Instance Attribute Summary collapse
-
#media ⇒ Object
Returns the value of attribute media.
-
#message ⇒ Object
Returns the value of attribute message.
-
#mime_type ⇒ Object
Returns the value of attribute mime_type.
-
#role ⇒ Object
Returns the value of attribute role.
-
#tool_calls ⇒ Object
Returns the value of attribute tool_calls.
Instance Method Summary collapse
-
#initialize(role:, message:, media: nil, mime_type: nil, tool_calls: nil) ⇒ ChatMessage
constructor
A new instance of ChatMessage.
-
#to_h ⇒ Hash
Convert to hash for serialization.
Constructor Details
#initialize(role:, message:, media: nil, mime_type: nil, tool_calls: nil) ⇒ ChatMessage
Returns a new instance of ChatMessage.
24 25 26 27 28 29 30 |
# File 'lib/conductor/workflow/llm/chat_message.rb', line 24 def initialize(role:, message:, media: nil, mime_type: nil, tool_calls: nil) @role = role @message = @media = media @mime_type = mime_type @tool_calls = tool_calls end |
Instance Attribute Details
#media ⇒ Object
Returns the value of attribute media.
17 18 19 |
# File 'lib/conductor/workflow/llm/chat_message.rb', line 17 def media @media end |
#message ⇒ Object
Returns the value of attribute message.
17 18 19 |
# File 'lib/conductor/workflow/llm/chat_message.rb', line 17 def @message end |
#mime_type ⇒ Object
Returns the value of attribute mime_type.
17 18 19 |
# File 'lib/conductor/workflow/llm/chat_message.rb', line 17 def mime_type @mime_type end |
#role ⇒ Object
Returns the value of attribute role.
17 18 19 |
# File 'lib/conductor/workflow/llm/chat_message.rb', line 17 def role @role end |
#tool_calls ⇒ Object
Returns the value of attribute tool_calls.
17 18 19 |
# File 'lib/conductor/workflow/llm/chat_message.rb', line 17 def tool_calls @tool_calls end |
Instance Method Details
#to_h ⇒ Hash
Convert to hash for serialization
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/conductor/workflow/llm/chat_message.rb', line 34 def to_h result = { 'role' => @role, 'message' => @message } result['media'] = @media if @media && !@media.empty? result['mimeType'] = @mime_type if @mime_type result['toolCalls'] = @tool_calls.map(&:to_h) if @tool_calls && !@tool_calls.empty? result end |