Skip to content

Conversation

@rafaelsideguide
Copy link
Collaborator

No description provided.

Copy link
Collaborator

@tomkosm tomkosm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, commented on a few minor mostly type related stuff

blockAds: Optional[bool] = None
proxy: Optional[Literal["basic", "stealth"]] = None

class Action(pydantic.BaseModel):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should make a different type for each action, so its clear what the arguments for each action are?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You then can make action be a union ie Union[WaitAction, ClickAction, ScreenshotAction]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea!

"""
crawl_response = self.async_crawl_url(url, params, idempotency_key)
if crawl_response['success'] and 'id' in crawl_response:
return CrawlWatcher(crawl_response['id'], self)
else:
raise Exception("Crawl job failed to start")

def map_url(self, url: str, params: Optional[Dict[str, Any]] = None) -> Any:
def map_url(self, url: str, params: Optional[Dict[str, Any]] = None) -> MapResponse:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, maybe we should use the type for params

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

await asyncio.sleep(backoff_factor * (2 ** attempt))
continue
if response.status != 200:
await self._handle_error(response, "make POST request")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this mean?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a retry for 502s

for attempt in range(retries):
try:
async with session.post(url, headers=headers, json=data) as response:
if response.status == 502:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this rate limit?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope. It's retry

for attempt in range(retries):
try:
async with session.get(url, headers=headers) as response:
if response.status == 502:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have this twice, maybe abstract it

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first is get, second is post

else:
raise Exception(f'Failed to start crawl. Error: {response.get("error")}')

async def async_crawl_url(self, url: str, params: Optional[Dict[str, Any]] = None, idempotency_key: Optional[str] = None) -> CrawlResponse:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

params type missing here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

else:
raise Exception(f'Job failed or was stopped. Status: {status_data["status"]}')

async def map_url(self, url: str, params: Optional[Dict[str, Any]] = None) -> MapResponse:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@nickscamara
Copy link
Member

Add origin param to the json body saying python-sdk

@rafaelsideguide
Copy link
Collaborator Author

Add origin param to the json body saying python-sdk

done

@rafaelsideguide
Copy link
Collaborator Author

@nickscamara can you take a look and publish this one pls?

@ftonato ftonato requested a review from Copilot April 8, 2025 16:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • apps/python-sdk/requirements.txt: Language not supported

Comment on lines +515 to 517
this.init();
}

Copy link

Copilot AI Apr 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The async initialization in this.init() is not awaited, which might lead to requests using a default version before the SDK version is properly set. Consider ensuring that initialization is complete (for example, by awaiting the promise) before processing further operations that depend on the version.

Suggested change
this.init();
}
}
static async create(config: FirecrawlAppConfig): Promise<FirecrawlApp> {
const instance = new FirecrawlApp(config);
await instance.init();
return instance;
}

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nickscamara nickscamara requested a review from mogery as a code owner April 18, 2025 08:28
@nickscamara nickscamara merged commit 29b36c5 into main Apr 18, 2025
1 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants