class RubyLLM::MCP::Responses::SamplingCreateMessage
def call
def call @coordinator.request(sampling_create_message_body, add_id: false, wait_for_response: false) end
def format_content(content)
def format_content(content) if content.is_a?(RubyLLM::Content) if context.text.none? && content.attachments.any? attachment = content.attachments.first { type: attachment.type, data: attachment.content, mime_type: attachment.mime_type } else { type: "text", text: content.text } end else { type: "text", text: content } end end
def initialize(coordinator, id:, message:, model:)
def initialize(coordinator, id:, message:, model:) @coordinator = coordinator @id = id @message = message @model = model end
def sampling_create_message_body
def sampling_create_message_body { jsonrpc: "2.0", id: @id, result: { role: @message.role, content: format_content(@message.content), model: @model, # TODO: We are going to assume it was a endTurn # Look into getting RubyLLM to expose stopReason in message response stopReason: "endTurn" } } end