You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`ROCAUCEvaluator`, `KolmogorovSmirnovEvaluator`) are recognized automatically. For custom report evaluators, pass them via `custom_report_evaluator_types`:
476
599
477
600
```python {test="skip" lint="skip"}
478
601
from pydantic_evals import Dataset
@@ -501,6 +624,7 @@ as interactive visualizations:
501
624
502
625
- **Confusion matrices** are displayed as heatmaps
503
626
- **Precision-recall curves** are rendered as line charts with AUC in the legend
627
+
- **Line plots** (ROC curves, KS plots, etc.) are rendered as line charts with configurable axes
504
628
- **Scalar results** are shown as labeled values
505
629
- **Tables** are rendered as formatted data tables
506
630
@@ -520,9 +644,11 @@ from pydantic_evals.evaluators import (
520
644
ConfusionMatrixEvaluator,
521
645
Evaluator,
522
646
EvaluatorContext,
647
+
KolmogorovSmirnovEvaluator,
523
648
PrecisionRecallEvaluator,
524
649
ReportEvaluator,
525
650
ReportEvaluatorContext,
651
+
ROCAUCEvaluator,
526
652
)
527
653
from pydantic_evals.reporting.analyses import ScalarResult
528
654
@@ -586,6 +712,18 @@ dataset = Dataset(
586
712
positive_from='assertions',
587
713
positive_key='is_correct',
588
714
),
715
+
ROCAUCEvaluator(
716
+
score_from='scores',
717
+
score_key='confidence',
718
+
positive_from='assertions',
719
+
positive_key='is_correct',
720
+
),
721
+
KolmogorovSmirnovEvaluator(
722
+
score_from='scores',
723
+
score_key='confidence',
724
+
positive_from='assertions',
725
+
positive_key='is_correct',
726
+
),
589
727
AccuracyEvaluator(),
590
728
],
591
729
)
@@ -597,6 +735,11 @@ for analysis in report.analyses:
Copy file name to clipboardExpand all lines: docs/ui/vercel-ai.md
+24-1Lines changed: 24 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Vercel AI Data Stream Protocol
2
2
3
-
Pydantic AI natively supports the [Vercel AI Data Stream Protocol](https://ai-sdk.dev/docs/ai-sdk-ui/stream-protocol#data-stream-protocol) to receive agent run input from, and stream events to, a [Vercel AI Elements](https://ai-sdk.dev/elements)frontend.
3
+
Pydantic AI natively supports the [Vercel AI Data Stream Protocol](https://ai-sdk.dev/docs/ai-sdk-ui/stream-protocol#data-stream-protocol) to receive agent run input from, and stream events to, a frontend using [AI SDK UI](https://ai-sdk.dev/docs/ai-sdk-ui/overview) hooks like [`useChat`](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-chat). You can optionally use [AI Elements](https://ai-sdk.dev/elements)for pre-built UI components.
4
4
5
5
!!! note
6
6
By default, the adapter targets AI SDK v5 for backwards compatibility. To use features introduced in AI SDK v6, set `sdk_version=6` on the adapter.
Protocol-control chunks such as `StartChunk`, `FinishChunk`, `StartStepChunk`, or `FinishStepChunk` are automatically filtered out — only the four data-carrying chunk types listed above are forwarded to the stream and preserved in `dump_messages`.
126
+
127
+
## Tool Approval
128
+
129
+
!!! note
130
+
Tool approval requires AI SDK UI v6 or later on the frontend.
131
+
132
+
Pydantic AI supports human-in-the-loop tool approval workflows with AI SDK UI, allowing users to approve or deny tool executions before they run. See the [deferred tool calls documentation](../deferred-tools.md#human-in-the-loop-tool-approval) for details on setting up tools that require approval.
133
+
134
+
To enable tool approval streaming, pass `sdk_version=6` to `dispatch_request`:
1. Emit `tool-approval-request` chunks when tools with `requires_approval=True` are called
145
+
2. Automatically extract approval responses from follow-up requests
146
+
3. Emit `tool-output-denied` chunks for rejected tools
147
+
148
+
On the frontend, AI SDK UI's [`useChat`](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-chat) hook handles the approval flow. You can use the [`Confirmation`](https://ai-sdk.dev/elements/components/confirmation) component from AI Elements for a pre-built approval UI, or build your own using the hook's `addToolApprovalResponse` function.
0 commit comments