Class: Firecrawl::Models::AgentOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/firecrawl/models/agent_options.rb

Overview

Options for starting an agent task.

Constant Summary collapse

FIELDS =
%i[
  urls prompt schema integration max_credits
  strict_constrain_to_urls model webhook
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(**kwargs) ⇒ AgentOptions

Returns a new instance of AgentOptions.

Raises:

  • (ArgumentError)


14
15
16
17
# File 'lib/firecrawl/models/agent_options.rb', line 14

def initialize(**kwargs)
  FIELDS.each { |f| instance_variable_set(:"@#{f}", kwargs[f]) }
  raise ArgumentError, "Agent prompt is required" if prompt.nil? || prompt.empty?
end

Instance Method Details

#to_hObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/firecrawl/models/agent_options.rb', line 19

def to_h
  {
    "urls" => urls,
    "prompt" => prompt,
    "schema" => schema,
    "integration" => integration,
    "maxCredits" => max_credits,
    "strictConstrainToURLs" => strict_constrain_to_urls,
    "model" => model,
    "webhook" => webhook.is_a?(Hash) ? webhook : webhook&.to_h,
  }.compact
end