Class: TurnKit::MessageProjection
- Inherits:
-
Object
- Object
- TurnKit::MessageProjection
- Defined in:
- lib/turnkit/message_projection.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(message) ⇒ MessageProjection
constructor
A new instance of MessageProjection.
- #to_h ⇒ Object
Constructor Details
#initialize(message) ⇒ MessageProjection
Returns a new instance of MessageProjection.
9 10 11 |
# File 'lib/turnkit/message_projection.rb', line 9 def initialize() @message = end |
Class Method Details
.for(messages) ⇒ Object
5 6 7 |
# File 'lib/turnkit/message_projection.rb', line 5 def self.for() .map { || new().to_h } end |
Instance Method Details
#to_h ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/turnkit/message_projection.rb', line 13 def to_h case .kind when "tool_call" { role: :assistant, content: .text, tool_calls: ..fetch("tool_calls", []) } when "tool_result" { role: :tool, content: .text, tool_call_id: .["tool_call_id"] } else { role: .role.to_sym, content: .text } end end |