Kward

Class: Kward::Tools::FetchRaw

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

Overview

Fetches bounded raw content from a specific URL.

Instance Attribute Summary

Attributes inherited from Base

#name

Instance Method Summary collapse

Methods inherited from Base

#schema

Constructor Details

#initialize(web_fetch:) ⇒ FetchRaw

Builds the tool schema and stores the execution dependency.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/kward/tools/fetch_raw.rb', line 11

def initialize(web_fetch:)
  @web_fetch = web_fetch
  super(
    "fetch_raw",
    "Fetch bounded raw content from a specific URL.",
    properties: {
      url: {
        type: "string",
        description: "HTTP or HTTPS URL to fetch."
      },
      max_bytes: {
        type: "integer",
        description: "Maximum returned content bytes; default 16384, max 131072."
      },
      accept: {
        type: "string",
        description: "Optional HTTP Accept header."
      }
    },
    required: ["url"]
  )
end

Instance Method Details

#call(args, _conversation, cancellation: nil) ⇒ Object

Executes the tool and returns model-facing output text.



35
36
37
# File 'lib/kward/tools/fetch_raw.rb', line 35

def call(args, _conversation, cancellation: nil)
  @web_fetch.fetch_raw(args)
end