Spaces:
Configuration error
Configuration error
| from agency_swarm.tools import BaseTool | |
| from pydantic import Field | |
| import requests | |
| import os | |
| # Assuming Firecrawl API requires an API key | |
| firecrawl_api_key = os.getenv("FIRECRAWL_API_KEY") | |
| firecrawl_base_url = "https://api.firecrawl.com/data" | |
| class FirecrawlDataScraperTool(BaseTool): | |
| """ | |
| This tool interfaces with Firecrawl to gather additional data based on identified gaps or areas needing improvement in the report. | |
| """ | |
| gap_description: str = Field( | |
| ..., description="Description of the identified gap or area needing improvement in the report." | |
| ) | |
| def run(self): | |
| """ | |
| Interfaces with Firecrawl to gather additional data based on the provided gap description. | |
| """ | |
| # Prepare the request to Firecrawl API | |
| headers = { | |
| "Authorization": f"Bearer {firecrawl_api_key}", | |
| "Content-Type": "application/json" | |
| } | |
| payload = { | |
| "query": self.gap_description | |
| } | |
| # Send the request to Firecrawl API | |
| response = requests.post(firecrawl_base_url, json=payload, headers=headers) | |
| # Check if the request was successful | |
| if response.status_code == 200: | |
| data = response.json() | |
| return f"Data gathered from Firecrawl: {data}" | |
| else: | |
| return f"Failed to gather data from Firecrawl. Status code: {response.status_code}, Error: {response.text}" |