Add Web Scraping and Compliance Reasoning

implementationChallenge

Prompt Content

Enhance your `PolicyExtractorAgent` to include a tool that performs web scraping using `BeautifulSoup` and `requests` (or `Playwright` for dynamic content) to fetch policy documents from specified URLs. Create a new agent method or a separate agent responsible for `ComplianceReport` generation. This agent should take a `TaxExemptionPolicy` and a `business_scenario` as input, use `Gemini 2.5 Pro` to reason about compliance, and output a validated `ComplianceReport`.

```python
from bs4 import BeautifulSoup
import requests

class WebScraperTool:
    def scrape_url(self, url: str) -> str:
        response = requests.get(url)
        soup = BeautifulSoup(response.text, 'html.parser')
        return soup.get_text()

class ComplianceAgent(PydanticAI):
    def generate_report(self, policy: TaxExemptionPolicy, scenario: str) -> ComplianceReport:
        # LLM call with prompt for compliance reasoning
        pass

# Integrate WebScraperTool into PolicyExtractorAgent or orchestrate externally
# agent_with_scraper = PolicyExtractorAgent(llm_model=model, tools=[WebScraperTool()])
```

Try this prompt

Open the workspace to execute this prompt with free credits, or use your own API keys for unlimited usage.

Usage Tips

Copy the prompt and paste it into your preferred AI tool (Claude, ChatGPT, Gemini)

Customize placeholder values with your specific requirements and context

For best results, provide clear examples and test different variations