TextMessage¶
Assistant text response.
Class: RobotLab::TextMessage¶
Constructor¶
Parameters:
| Name | Type | Description |
|---|---|---|
content |
String |
Response text |
Attributes¶
content¶
The response text.
role¶
Always returns :assistant.
Methods¶
to_h¶
Hash representation.
Returns:
to_json¶
JSON representation.
Examples¶
Basic Response¶
In Robot Results¶
result = robot.run(state: state)
# Extract text messages
result.output.each do |msg|
if msg.is_a?(TextMessage)
puts msg.content
end
end
Filtering Text Content¶
# Get only text responses from results
text_responses = state.results.flat_map(&:output).select do |msg|
msg.is_a?(TextMessage)
end.map(&:content)