struct OpenRouter::Message

Defined in:

openrouter/types/message.cr

Constructors

Class Method Summary

Instance Method Summary

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


[View source]
def self.new(tool_call : ToolCall) #

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()


[View source]

Class Method Detail

def self.from_json(json : JSON::Any) #

[View source]

Instance Method Detail

def add_tool_call(tool_call : ToolCall) #

[View source]
def add_tool_call(name : String, arguments : Array(ToolCallArgument) = [] of ToolCallArgument, tool_call_type : String = "function", tool_call_id : String | Nil = nil) #

[View source]
def content : Content #

[View source]
def content=(content : Content) #

[View source]
def content_string : String #

Get the content, or in case of a multi-modal message, the content of the first part. Get the content, or in case of a multi-modal message, the content of the first part.


[View source]
def length : Int32 #

[View source]
def multi_modal? : Bool #

Check if content is an Array


[View source]
def name : String | Nil #

[View source]
def name=(name : String | Nil) #

[View source]
def role : Role | Nil #

Common fields


[View source]
def role=(role : Role | Nil) #

Common fields


[View source]
def to_json(io : IO) #

[View source]
def to_json(json : JSON::Builder) #

[View source]
def tool_call_id : String | Nil #

Optional fields for specific roles


[View source]
def tool_call_id=(tool_call_id : String | Nil) #

Optional fields for specific roles


[View source]
def tool_calls : Array(ToolCall) | Nil #

[View source]
def tool_calls=(tool_calls : Array(ToolCall) | Nil) #

[View source]