Class: Tools::WebGet

Inherits:
Base
  • Object
show all
Defined in:
lib/tools/web_get.rb

Overview

Fetches content from a URL via HTTP GET. Returns the response body as plain text, truncated to Anima::Settings.max_web_response_bytes to prevent memory issues.

Only http and https schemes are allowed.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize, schema

Constructor Details

This class inherits a constructor from Tools::Base

Class Method Details

.descriptionObject



13
# File 'lib/tools/web_get.rb', line 13

def self.description = "Fetch content from a URL via HTTP GET and return the response body"

.input_schemaObject



15
16
17
18
19
20
21
22
23
# File 'lib/tools/web_get.rb', line 15

def self.input_schema
  {
    type: "object",
    properties: {
      url: {type: "string", description: "The URL to fetch (http or https)"}
    },
    required: ["url"]
  }
end

.tool_nameObject



11
# File 'lib/tools/web_get.rb', line 11

def self.tool_name = "web_get"

Instance Method Details

#execute(input) ⇒ String, Hash

Parameters:

  • input (Hash<String, Object>)

    string-keyed hash from the Anthropic API

Returns:

  • (String)

    response body (possibly truncated)

  • (Hash)

    with :error key on failure



28
29
30
# File 'lib/tools/web_get.rb', line 28

def execute(input)
  validate_and_fetch(input["url"].to_s)
end