from __future__ import annotations
from pydantic import BaseModel, Field
from app.agents.d3.registry import D3Template, register
class PieSlice(BaseModel):
label: str
value: float = Field(ge=0)
class PieChartData(BaseModel):
title: str = ""
metric_label: str = "Value"
data: list[PieSlice] = Field(min_length=2, max_length=16)
_HTML = """
"""
register(D3Template(id="pie_chart", family="chart", title="Pie chart", when_to_use="Show part-to-whole proportions for one explicitly selected metric.", data_requirements="Two to sixteen named non-negative values that form one meaningful whole.", schema=PieChartData, html_template=_HTML, golden_sample=PieChartData(title="Share by model", metric_label="Average score", data=[PieSlice(label="Qwen", value=22.6), PieSlice(label="DeepSeek", value=21.7), PieSlice(label="Base", value=15.0), PieSlice(label="SFT", value=23.1)])))