Prompt Content
Using `Pydantic AI`, define an agent that takes raw policy text as input and attempts to extract structured `TaxExemptionPolicy` objects. Integrate `Gemini 2.5 Pro` as the backbone LLM for this extraction. Ensure your agent is configured to produce outputs that strictly adhere to your `TaxExemptionPolicy` model, using Pydantic AI's built-in validation.
```python
from pydantic_ai import PydanticAI
from google.generativeai.client import get_default_retriever
from google.generativeai.generative_models import GenerativeModel
from google.generativeai.types import FunctionDeclaration
# Initialize Gemini 2.5 Pro (ensure proper setup with your API key)
model = GenerativeModel('gemini-1.5-pro-latest') # Or gemini-2.5-pro if available
class PolicyExtractorAgent(PydanticAI):
def extract_policy(self, policy_text: str) -> TaxExemptionPolicy:
"""Extracts structured tax exemption policy details from raw text."""
return self.llm_call(
func=TaxExemptionPolicy, # Target Pydantic model for structured output
prompt=f"Analyze the following policy text and extract a TaxExemptionPolicy object:\n\n{policy_text}"
)
# Instantiate and test the agent
# agent = PolicyExtractorAgent(llm_model=model)
# policy_data = agent.extract_policy(policy_text='...')
# print(policy_data)
```Try this prompt
Open the workspace to execute this prompt with free credits, or use your own API keys for unlimited usage.
Related Prompts
Explore similar prompts from our community
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