Class: AssistantMessage
- Inherits:
-
BaseStruct
- Object
- Dry::Struct
- BaseStruct
- AssistantMessage
- Defined in:
- lib/llm_gateway/adapters/structs.rb
Constant Summary collapse
- ContentBlock =
Types.Instance(TextContent) | Types.Instance(ReasoningContent) | Types.Instance(ToolCall)
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.new(attributes) ⇒ Object
106 107 108 109 110 |
# File 'lib/llm_gateway/adapters/structs.rb', line 106 def self.new(attributes) attrs = attributes.to_h.transform_keys(&:to_sym) attrs[:content] = Array(attrs[:content]).map { |block| build_content_block(block) } super(attrs) end |
Instance Method Details
#to_h ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/llm_gateway/adapters/structs.rb', line 112 def to_h result = { id: id, model: model, usage: usage, role: role, stop_reason: stop_reason, provider: provider, api: api, content: content.map(&:to_h) } result[:error_message] = unless .nil? result end |