Skip to main content
Loading navigation
Back to prompt library

Define Pydantic Models for Policy & Compliance

Linked challenge: Global Compliance Intelligence Agent

Prompt source

planning17 lines5 sectionsNo variables1 code block
Begin by defining several Pydantic models that will represent the structured data your agent will extract and generate. Create a `TaxExemptionPolicy` model with fields like `entity_type`, `exemption_type`, `scope`, `conditions`, and `valid_until`. Also, define a `ComplianceReport` model that includes `compliance_status`, `recommendations`, and `relevant_clauses`. These models will guide your agent's output and validation logic.

```python
from pydantic import BaseModel, Field, conlist
from typing import Optional

class TaxExemptionPolicy(BaseModel):
    entity_type: str = Field(..., description='Type of entity eligible for exemption (e.g., foreign_cloud_provider)')
    exemption_type: str = Field(..., description='Type of tax exemption (e.g., income_tax, import_duty)')
    scope: str = Field(..., description='Specific scope of the exemption (e.g., services_sold_outside_india)')
    conditions: conlist(str, min_length=1) = Field(..., description='List of conditions that must be met for the exemption')
    valid_until: Optional[int] = Field(None, description='Year until which the exemption is valid, if applicable')

class ComplianceReport(BaseModel):
    compliance_status: str = Field(..., description='Overall compliance status (e.g., Compliant, Non-Compliant, Conditional)')
    recommendations: conlist(str, min_length=1) = Field(..., description='Actionable recommendations for ensuring compliance')
    relevant_clauses: conlist(str, min_length=1) = Field(..., description='List of relevant policy clauses or sections')

print(TaxExemptionPolicy.model_json_schema())
print(ComplianceReport.model_json_schema())
```