Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥
TypeScript aiai-agentsai-crawlerai-scrapingai-searchcrawlerdata-extractionhtml-to-markdownllmmarkdownscraperscrapingweb-crawlerweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
Merge branch 'main' into sdk-improv/async
Rafael Millere425667005e7
diff --cc apps/python-sdk/firecrawl/firecrawl.pyindex adedce9c5,436f8764a..7dafbf489--- a/apps/python-sdk/firecrawl/firecrawl.py+++ b/apps/python-sdk/firecrawl/firecrawl.py@@@ -1124,40 -647,16 +1125,40 @@@ class FirecrawlAppelse:self._handle_error(response, "check batch scrape errors")- def extract(self, urls: Optional[List[str]] = None, params: Optional[ExtractParams] = None) -> Any:+ def extract(+ self,- urls: List[str],++ urls: Optional[List[str]] = None,+ params: Optional[ExtractParams] = None) -> ExtractResponse[Any]:"""- Extracts information from a URL using the Firecrawl API.+ Extract structured information from URLs.Args:- urls (Optional[List[str]]): The URLs to extract information from.- params (Optional[ExtractParams]): Additional parameters for the extract request.+ urls: URLs to extract from++ params: See ExtractParams model:++ Extraction Config:+ * prompt - Custom extraction prompt+ * schema - JSON schema/Pydantic model+ * systemPrompt - System context++ Behavior Options:+ * allowExternalLinks - Follow external links+ * enableWebSearch - Enable web search+ * includeSubdomains - Include subdomains+ * showSources - Include source URLs++ Scraping Options:+ * scrapeOptions - Page scraping configReturns:- Union[ExtractResponse, ErrorResponse]: The response from the extract operation.+ ExtractResponse with:+ * Structured data matching schema+ * Source information if requested+ * Success/error status++ Raises:+ ValueError: If prompt/schema missing or extraction fails"""headers = self._prepare_headers()@@@ -1177,9 -679,11 +1181,11 @@@'enableWebSearch': params.get('enable_web_search', params.get('enableWebSearch', False)),'showSources': params.get('show_sources', params.get('showSources', False)),'schema': schema,- 'origin': 'api-sdk'+ 'origin': f'python-sdk@{get_version()}'}+ if not request_data['urls']:+ request_data['urls'] = []# Only add prompt and systemPrompt if they existif params.get('prompt'):request_data['prompt'] = params['prompt']@@@ -1654,36 -1113,9 +1660,38 @@@# Raise an HTTPError with the custom message and attach the responseraise requests.exceptions.HTTPError(message, response=response)- def deep_research(self, query: str, params: Optional[Union[Dict[str, Any], DeepResearchParams]] = None,- on_activity: Optional[Callable[[Dict[str, Any]], None]] = None,- on_source: Optional[Callable[[Dict[str, Any]], None]] = None) -> Dict[str, Any]:+ def _get_error_message(self, status_code: int, action: str, error_message: str, error_details: str) -> str:+ """+ Generate a standardized error message based on HTTP status code.++ Args:+ status_code (int): The HTTP status code from the response+ action (str): Description of the action that was being performed+ error_message (str): The error message from the API response+ error_details (str): Additional error details from the API response++ Returns:+ str: A formatted error message+ """+ if status_code == 402:+ return f"Payment Required: Failed to {action}. {error_message} - {error_details}"++ elif status_code == 403:++ message = f"Website Not Supported: Failed to {action}. {error_message} - {error_details}"+ elif status_code == 408:+ return f"Request Timeout: Failed to {action} as the request timed out. {error_message} - {error_details}"+ elif status_code == 409:+ return f"Conflict: Failed to {action} due to a conflict. {error_message} - {error_details}"+ elif status_code == 500:+ return f"Internal Server Error: Failed to {action}. {error_message} - {error_details}"+ else:+ return f"Unexpected error during {action}: Status code {status_code}. {error_message} - {error_details}"++ def deep_research(+ self,+ query: str,+ params: Optional[Union[Dict[str, Any], DeepResearchParams]] = None,+ on_activity: Optional[Callable[[Dict[str, Any]], None]] = None,+ on_source: Optional[Callable[[Dict[str, Any]], None]] = None) -> DeepResearchStatusResponse:"""Initiates a deep research operation on a given query and polls until completion.