File size: 1,820 Bytes
097eaf0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php

declare(strict_types=1);

namespace Firecrawl\Models;

final class AgentOptions
{
    /**
     * @param list<string>|null          $urls
     * @param array<string, mixed>|null  $schema
     */
    private function __construct(
        private readonly ?array $urls = null,
        private readonly ?string $prompt = null,
        private readonly ?array $schema = null,
        private readonly ?string $integration = null,
        private readonly ?int $maxCredits = null,
        private readonly ?bool $strictConstrainToURLs = null,
        private readonly ?string $model = null,
        private readonly ?WebhookConfig $webhook = null,
    ) {}

    /**
     * @param list<string>|null         $urls
     * @param array<string, mixed>|null $schema
     */
    public static function with(
        ?array $urls = null,
        ?string $prompt = null,
        ?array $schema = null,
        ?string $integration = null,
        ?int $maxCredits = null,
        ?bool $strictConstrainToURLs = null,
        ?string $model = null,
        ?WebhookConfig $webhook = null,
    ): self {
        return new self(
            $urls, $prompt, $schema, $integration,
            $maxCredits, $strictConstrainToURLs, $model, $webhook,
        );
    }

    /** @return array<string, mixed> */
    public function toArray(): array
    {
        $fields = [
            'urls' => $this->urls,
            'prompt' => $this->prompt,
            'schema' => $this->schema,
            'integration' => $this->integration,
            'maxCredits' => $this->maxCredits,
            'strictConstrainToURLs' => $this->strictConstrainToURLs,
            'model' => $this->model,
            'webhook' => $this->webhook?->toArray(),
        ];

        return array_filter($fields, fn (mixed $v): bool => $v !== null);
    }
}