Skip to content

Commit 2412c16

Browse files
committed
fix(agent): Firecrawl crawling
1 parent 22a3555 commit 2412c16

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/agent/src/Toolbox/Tool/Firecrawl.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\AI\Agent\Toolbox\Attribute\AsTool;
1515
use Symfony\Contracts\HttpClient\HttpClientInterface;
16+
use Symfony\Contracts\HttpClient\ResponseInterface;
1617

1718
/**
1819
* @author Guillaume Loulier <[email protected]>
@@ -78,11 +79,17 @@ public function crawl(string $url): array
7879

7980
$crawlingPayload = $response->toArray();
8081

81-
while ('scraping' === $this->httpClient->request('GET', \sprintf('%s/v1/crawl/%s', $this->endpoint, $crawlingPayload['id']))->toArray()['status']) {
82+
$scrapingStatusRequest = fn (array $crawlingPayload): ResponseInterface => $this->httpClient->request('GET', \sprintf('%s/v1/crawl/%s', $this->endpoint, $crawlingPayload['id']), [
83+
'auth_bearer' => $this->apiKey,
84+
]);
85+
86+
while ('scraping' === $scrapingStatusRequest($crawlingPayload)->toArray()['status']) {
8287
usleep(500);
8388
}
8489

85-
$scrapingPayload = $this->httpClient->request('GET', \sprintf('%s/v1/crawl/%s', $this->endpoint, $crawlingPayload['id']));
90+
$scrapingPayload = $this->httpClient->request('GET', \sprintf('%s/v1/crawl/%s', $this->endpoint, $crawlingPayload['id']), [
91+
'auth_bearer' => $this->apiKey,
92+
]);
8693

8794
$finalPayload = $scrapingPayload->toArray();
8895

0 commit comments

Comments
 (0)