Class: Langchain::ToolResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/langchain/tool_response.rb

Overview

ToolResponse represents the standardized output of a tool. It can contain either text content or an image URL.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content: nil, image_url: nil) ⇒ ToolResponse

Initializes a new ToolResponse.

Parameters:

  • content (String) (defaults to: nil)

    The text content of the response.

  • image_url (String, nil) (defaults to: nil)

    Optional URL to an image.

Raises:

  • (ArgumentError)
[View source]

13
14
15
16
17
18
# File 'lib/langchain/tool_response.rb', line 13

def initialize(content: nil, image_url: nil)
  raise ArgumentError, "Either content or image_url must be provided" if content.nil? && image_url.nil?

  @content = content
  @image_url = image_url
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.


7
8
9
# File 'lib/langchain/tool_response.rb', line 7

def content
  @content
end

#image_urlObject (readonly)

Returns the value of attribute image_url.


7
8
9
# File 'lib/langchain/tool_response.rb', line 7

def image_url
  @image_url
end

Instance Method Details

#to_sObject

[View source]

20
21
22
# File 'lib/langchain/tool_response.rb', line 20

def to_s
  content.to_s
end