struct OpenRouter::Message
- OpenRouter::Message
- Struct
- Value
- Object
Defined in:
openrouter/types/message.crConstructors
-
.new(role : Role, content : Content, name : String | Nil = nil, tool_call_id : String | Nil = nil, tool_calls : Array(ToolCall) | Nil = nil)
Initialize for user/assistant/system messages
-
.new(tool_call : ToolCall)
Create a tool result message.
Class Method Summary
Instance Method Summary
- #add_tool_call(tool_call : ToolCall)
- #add_tool_call(name : String, arguments : Array(ToolCallArgument) = [] of ToolCallArgument, tool_call_type : String = "function", tool_call_id : String | Nil = nil)
- #content : Content
- #content=(content : Content)
-
#content_string : String
Get the content, or in case of a multi-modal message, the content of the first part.
-
#multi_modal? : Bool
Check if content is an Array
- #name : String | Nil
- #name=(name : String | Nil)
-
#role : Role | Nil
Common fields
-
#role=(role : Role | Nil)
Common fields
- #to_json(io : IO)
- #to_json(json : JSON::Builder)
-
#tool_call_id : String | Nil
Optional fields for specific roles
-
#tool_call_id=(tool_call_id : String | Nil)
Optional fields for specific roles
- #tool_calls : Array(ToolCall) | Nil
- #tool_calls=(tool_calls : Array(ToolCall) | Nil)
Constructor Detail
def self.new(role : Role, content : Content, name : String | Nil = nil, tool_call_id : String | Nil = nil, tool_calls : Array(ToolCall) | Nil = nil)
#
Initialize for user/assistant/system messages
Create a tool result message.
Role will be Role::Tool @name will be set to tool_call.name @tool_call_id will be set to tool_call.id @content will be set to serializd string of tool_call.arguments.to_json()
Class Method Detail
Instance Method Detail
def add_tool_call(name : String, arguments : Array(ToolCallArgument) = [] of ToolCallArgument, tool_call_type : String = "function", tool_call_id : String | Nil = nil)
#
def content_string : String
#
Get the content, or in case of a multi-modal message, the content of the first part.