(config, ax)
| 524 | |
| 525 | |
| 526 | def chart_5_token_budget(config, ax): |
| 527 | pb = PromptBuilder("You are a structured assistant. Always return JSON.", config) |
| 528 | _, budget = pb.build( |
| 529 | "Explain the token budget mechanism", |
| 530 | ["Return only valid JSON.", "Include summary and confidence keys."], |
| 531 | ) |
| 532 | slots = {k: v for k, v in budget.report().items() if v > 0} |
| 533 | if not slots: |
| 534 | return |
| 535 | labels = [k.replace("_", "\n") for k in slots.keys()] |
| 536 | sizes = list(slots.values()) |
| 537 | remaining = max(0, config.total_tokens - sum(sizes)) |
| 538 | if remaining > 0: |
| 539 | labels.append("remaining") |
| 540 | sizes.append(remaining) |
| 541 | palette = [CHART_COLOR_DARK, CHART_COLOR_PASS, CHART_COLOR_ACCENT, |
| 542 | CHART_COLOR_NEUTRAL, CHART_GRID] |
| 543 | wedges, texts, autotexts = ax.pie( |
| 544 | sizes, labels=labels, autopct="%1.0f%%", |
| 545 | colors=palette[:len(labels)], startangle=140, pctdistance=0.75, |
| 546 | wedgeprops={"edgecolor": "white", "linewidth": 2}, |
| 547 | ) |
| 548 | for t in texts: t.set_fontsize(8); t.set_color(CHART_COLOR_DARK) |
| 549 | for at in autotexts: at.set_fontsize(8); at.set_color("white"); at.set_fontweight("bold") |
| 550 | ax.set_title(f"Token Budget Allocation\n(total: {config.total_tokens} tokens)", |
| 551 | fontsize=11, fontweight="bold", color=CHART_COLOR_DARK, pad=10) |
| 552 | |
| 553 | |
| 554 | def chart_6_quality_scores(records, ax): |
no test coverage detected