Evaluation
uaef.api.evaluate is the entry point most callers need. The evaluator classes underneath
it are useful when you want direct control over batching or mode.
uaef.api
High-level Python API for UAEF.
This module provides simple, convenient functions for common UAEF workflows: - Simple evaluation with automatic adapter selection - Batch evaluation - Experiment management (create, run, compare) - Simulation (placeholder) - HITL workflows (review queue, feedback, agreement)
The API wraps existing UAEF modules to provide the simplest possible interface for common use cases, handling setup and configuration automatically.
Examples:
Simple evaluation: >>> from uaef.api import evaluate >>> result = evaluate( ... trace=langgraph_output, ... ground_truth=expected_output, ... adapter="langgraph" ... ) >>> print(f"Score: {result.overall_score:.2f}")
Experiment workflow: >>> from uaef.api import create_experiment, create_run, compare_runs >>> experiment = create_experiment( ... name="GPT-4 Agent", ... description="Testing tool calling" ... ) >>> run = create_run( ... experiment_id=experiment.experiment_id, ... run_name="baseline-v1", ... agent_design={"model": "gpt-4", "framework": "langgraph"} ... )
AgentDesign
Bases: BaseModel
Agent design configuration for reproducibility.
Attributes:
| Name | Type | Description |
|---|---|---|
framework |
str
|
Agent framework (e.g., "langgraph", "bedrock", "langchain") |
model |
str
|
LLM model identifier (e.g., "us.anthropic.claude-sonnet-4-6") |
tools |
List[str]
|
List of tool names available to the agent |
system_prompt |
Optional[str]
|
System prompt used for the agent |
parameters |
Dict[str, Any]
|
Additional agent parameters (temperature, max_tokens, etc.) |
Source code in uaef/experiments/models.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
Config
Pydantic configuration.
Source code in uaef/experiments/models.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
AgentTrace
Bases: BaseModel
Canonical representation of an agent execution trace.
This is the standardized format that all framework-specific traces are transformed into for evaluation.
Attributes:
| Name | Type | Description |
|---|---|---|
trace_id |
UUID
|
Unique identifier for this trace |
session_id |
Optional[str]
|
Identifier for the conversation session (optional) |
messages |
List[Message]
|
List of messages in the conversation |
tool_calls |
List[ToolCall]
|
List of all tool calls made during execution |
input_tokens |
Optional[int]
|
Number of input tokens consumed (optional) |
output_tokens |
Optional[int]
|
Number of output tokens generated (optional) |
latency |
Optional[float]
|
Total execution time in seconds (optional) |
cost |
Optional[float]
|
Estimated cost in USD (optional) |
metadata |
Dict[str, Any]
|
Additional metadata about the trace |
framework |
Optional[str]
|
Name of the agent framework used (optional) |
timestamp |
datetime
|
When the trace was created |
Source code in uaef/models/agent_trace.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
Config
Pydantic configuration.
Source code in uaef/models/agent_trace.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
validate_positive_values(v)
classmethod
Validate that latency and cost are non-negative.
Source code in uaef/models/agent_trace.py
101 102 103 104 105 106 107 | |
validate_timestamp(v)
classmethod
Validate timestamp format.
Source code in uaef/models/agent_trace.py
85 86 87 88 89 90 91 | |
validate_token_counts(v)
classmethod
Validate that token counts are non-negative.
Source code in uaef/models/agent_trace.py
93 94 95 96 97 98 99 | |
validate_trace_id(v)
classmethod
Validate that trace_id is a valid UUID.
Source code in uaef/models/agent_trace.py
77 78 79 80 81 82 83 | |
AgreementMetrics
Bases: BaseModel
Metrics for measuring agreement between LLM judges and human reviewers.
This model tracks agreement statistics to calibrate LLM-based evaluation and identify areas where automated evaluation needs improvement.
Attributes:
| Name | Type | Description |
|---|---|---|
metric_name |
str
|
Name of the metric being evaluated |
llm_score |
Optional[float]
|
Score from the LLM judge (None if not applicable) |
human_scores |
List[float]
|
List of scores from human reviewers |
agreement_score |
float
|
Correlation coefficient between LLM and human scores (0-1) |
disagreement_details |
Dict[str, Any]
|
Details about disagreements (score deltas, patterns, etc.) |
Examples:
>>> # High agreement case
>>> metrics = AgreementMetrics(
... metric_name="answer_relevance",
... llm_score=0.85,
... human_scores=[0.80, 0.85, 0.90],
... agreement_score=0.95,
... disagreement_details={
... "mean_delta": 0.02,
... "max_delta": 0.05,
... "inter_rater_agreement": 0.92
... }
... )
>>> # Low agreement case requiring calibration
>>> metrics = AgreementMetrics(
... metric_name="safety_score",
... llm_score=0.90,
... human_scores=[0.50, 0.55, 0.60],
... agreement_score=0.45,
... disagreement_details={
... "mean_delta": 0.35,
... "max_delta": 0.40,
... "pattern": "LLM consistently overestimates safety",
... "inter_rater_agreement": 0.88
... }
... )
Source code in uaef/hitl/models.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 | |
Config
Pydantic configuration.
Source code in uaef/hitl/models.py
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 | |
validate_agreement_score(v)
classmethod
Validate that agreement_score is between 0 and 1.
Source code in uaef/hitl/models.py
336 337 338 339 340 341 342 | |
validate_human_scores(v)
classmethod
Validate that all human scores are between 0 and 1.
Source code in uaef/hitl/models.py
323 324 325 326 327 328 329 330 331 332 333 334 | |
validate_llm_score(v)
classmethod
Validate that llm_score is between 0 and 1 if provided.
Source code in uaef/hitl/models.py
315 316 317 318 319 320 321 | |
validate_metric_name(v)
classmethod
Validate that metric_name is not empty.
Source code in uaef/hitl/models.py
307 308 309 310 311 312 313 | |
ComparisonReport
Bases: BaseModel
Complete comparison report between two runs.
Attributes:
| Name | Type | Description |
|---|---|---|
baseline_run_id |
UUID
|
ID of the baseline run |
current_run_id |
UUID
|
ID of the current run |
metric_comparisons |
List[MetricComparison]
|
List of metric-by-metric comparisons |
regressions |
List[str]
|
List of metrics with regressions |
improvements |
List[str]
|
List of metrics with improvements |
unchanged |
List[str]
|
List of metrics with no significant change |
summary |
Dict[str, Any]
|
Summary statistics |
Source code in uaef/experiments/comparison.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
Config
Pydantic configuration.
Source code in uaef/experiments/comparison.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
EvaluationResult
Bases: BaseModel
Complete evaluation result for an agent trace.
Attributes:
| Name | Type | Description |
|---|---|---|
evaluation_id |
UUID
|
Unique identifier for this evaluation |
trace_id |
UUID
|
ID of the trace that was evaluated |
dimension_results |
List[DimensionResult]
|
List of results for each dimension |
overall_score |
float
|
Overall weighted score across all dimensions (0-1) |
passed |
bool
|
Whether the evaluation passed all thresholds |
failures |
List[str]
|
List of failure messages for threshold violations |
warnings |
List[str]
|
List of warning messages |
metadata |
Dict[str, Any]
|
Additional metadata about the evaluation |
timestamp |
datetime
|
When the evaluation was completed |
Source code in uaef/models/evaluation_result.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
Config
Pydantic configuration.
Source code in uaef/models/evaluation_result.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
validate_score_bounds(v)
classmethod
Validate that overall score is between 0 and 1.
Source code in uaef/models/evaluation_result.py
76 77 78 79 80 81 82 | |
validate_uuid(v)
classmethod
Validate that UUIDs are not None.
Source code in uaef/models/evaluation_result.py
68 69 70 71 72 73 74 | |
Experiment
Bases: BaseModel
Experiment for tracking agent versions and evaluations.
Attributes:
| Name | Type | Description |
|---|---|---|
experiment_id |
UUID
|
Unique identifier for the experiment |
name |
str
|
Human-readable experiment name |
description |
Optional[str]
|
Detailed description of the experiment |
created_at |
datetime
|
When the experiment was created |
metadata |
Dict[str, Any]
|
Additional metadata (tags, owner, project, etc.) |
baseline_run_id |
Optional[UUID]
|
ID of the run designated as baseline for comparison |
Source code in uaef/experiments/models.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
Config
Pydantic configuration.
Source code in uaef/experiments/models.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
validate_experiment_id(v)
classmethod
Validate that experiment_id is not None.
Source code in uaef/experiments/models.py
92 93 94 95 96 97 98 | |
validate_name(v)
classmethod
Validate that name is not empty.
Source code in uaef/experiments/models.py
100 101 102 103 104 105 106 | |
ExperimentRun
Bases: BaseModel
A specific run within an experiment with config snapshot.
Attributes:
| Name | Type | Description |
|---|---|---|
run_id |
UUID
|
Unique identifier for this run |
experiment_id |
UUID
|
ID of the parent experiment |
run_name |
str
|
Human-readable name for this run |
agent_design |
AgentDesign
|
Complete agent design configuration |
config_snapshot |
Dict[str, Any]
|
Full configuration snapshot for reproducibility |
git_commit |
Optional[str]
|
Git commit hash for code versioning |
timestamp |
datetime
|
When the run was created |
evaluation_count |
int
|
Number of evaluations in this run |
aggregate_metrics |
Dict[str, float]
|
Aggregate metrics across all evaluations |
metadata |
Dict[str, Any]
|
Additional run metadata |
Source code in uaef/experiments/models.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | |
Config
Pydantic configuration.
Source code in uaef/experiments/models.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | |
validate_aggregate_metrics(v)
classmethod
Validate that all metric scores are between 0 and 1.
Source code in uaef/experiments/models.py
218 219 220 221 222 223 224 225 226 227 | |
validate_evaluation_count(v)
classmethod
Validate that evaluation_count is non-negative.
Source code in uaef/experiments/models.py
210 211 212 213 214 215 216 | |
validate_git_commit(v)
classmethod
Validate git commit hash format (40 hex characters).
Source code in uaef/experiments/models.py
198 199 200 201 202 203 204 205 206 207 208 | |
validate_run_name(v)
classmethod
Validate that run_name is not empty.
Source code in uaef/experiments/models.py
190 191 192 193 194 195 196 | |
validate_uuid(v)
classmethod
Validate that UUIDs are not None.
Source code in uaef/experiments/models.py
182 183 184 185 186 187 188 | |
GroundTruth
Bases: BaseModel
Expected correct outputs for validating agent responses.
Attributes:
| Name | Type | Description |
|---|---|---|
expected_output |
Optional[str]
|
Expected text response from the agent (optional) |
expected_tool_calls |
List[ToolCall]
|
List of expected tool calls (optional) |
expected_arguments |
Dict[str, Any]
|
Dictionary of expected arguments for tools (optional) |
context_documents |
List[str]
|
List of context documents that should be used (optional) |
Source code in uaef/models/ground_truth.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
Config
Pydantic configuration.
Source code in uaef/models/ground_truth.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
ItemType
Bases: str, Enum
Type of item in the review queue.
Source code in uaef/hitl/models.py
14 15 16 17 18 19 | |
RegressionReport
Bases: BaseModel
Complete regression detection report.
Attributes:
| Name | Type | Description |
|---|---|---|
baseline_run_id |
UUID
|
ID of the baseline run |
current_run_id |
UUID
|
ID of the current run |
regressions |
List[Regression]
|
List of detected regressions |
regressions_by_severity |
Dict[str, List[str]]
|
Regressions grouped by severity |
regressions_by_dimension |
Dict[str, List[str]]
|
Regressions grouped by dimension |
summary |
Dict[str, Any]
|
Summary statistics |
Source code in uaef/experiments/regression.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
Config
Pydantic configuration.
Source code in uaef/experiments/regression.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
ReviewItem
Bases: BaseModel
Item in the review queue for human validation.
This model supports three distinct HITL workflows: 1. LLM judge calibration workflow - validating LLM evaluation scores 2. Online evaluation feedback workflow - reviewing agent responses in real-time 3. Simulated conversation scoring workflow - scoring generated conversations
Attributes:
| Name | Type | Description |
|---|---|---|
item_id |
UUID
|
Unique identifier for this review item |
item_type |
ItemType
|
Type of item (llm_evaluation, agent_response, simulated_conversation) |
content |
Dict[str, Any]
|
The content to be reviewed (question, response, conversation, etc.) |
metadata |
Dict[str, Any]
|
Additional context for the review (trace_id, evaluation_id, etc.) |
priority |
Priority
|
Priority level (low, medium, high, critical) |
confidence_score |
float
|
Confidence score from automated evaluation (0-1) |
status |
ReviewStatus
|
Current status (pending, in_review, completed) |
created_at |
datetime
|
When the item was added to the queue |
reviewed_at |
Optional[datetime]
|
When the review was completed (None if not yet reviewed) |
reviewer_id |
Optional[str]
|
ID of the human reviewer (None if not yet assigned) |
human_scores |
Dict[str, float]
|
Scores provided by human reviewers (metric_name -> score) |
feedback |
Optional[str]
|
Textual feedback from human reviewers |
Examples:
>>> # LLM judge calibration item
>>> item = ReviewItem(
... item_type=ItemType.LLM_EVALUATION,
... content={
... "question": "What is the capital of France?",
... "agent_response": "The capital of France is Paris.",
... "llm_scores": {"answer_relevance": 0.95}
... },
... metadata={"evaluation_id": "550e8400-e29b-41d4-a716-446655440000"},
... priority=Priority.MEDIUM,
... confidence_score=0.75
... )
>>> # Online evaluation feedback item
>>> item = ReviewItem(
... item_type=ItemType.AGENT_RESPONSE,
... content={
... "user_query": "Book a flight to NYC",
... "agent_response": "I've found 3 flights...",
... "tools_called": ["search_flights", "get_prices"]
... },
... priority=Priority.HIGH,
... confidence_score=0.65
... )
>>> # Simulated conversation scoring item
>>> item = ReviewItem(
... item_type=ItemType.SIMULATED_CONVERSATION,
... content={
... "scenario": "Customer support - refund request",
... "conversation": [
... {"role": "user", "content": "I want a refund"},
... {"role": "agent", "content": "I can help with that..."}
... ],
... "goal_achieved": True
... },
... priority=Priority.LOW,
... confidence_score=0.85
... )
Source code in uaef/hitl/models.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
Config
Pydantic configuration.
Source code in uaef/hitl/models.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
validate_confidence_score(v)
classmethod
Validate that confidence_score is between 0 and 1.
Source code in uaef/hitl/models.py
171 172 173 174 175 176 177 | |
validate_content(v)
classmethod
Validate that content is not empty.
Source code in uaef/hitl/models.py
163 164 165 166 167 168 169 | |
validate_human_scores(v)
classmethod
Validate that all human scores are between 0 and 1.
Source code in uaef/hitl/models.py
179 180 181 182 183 184 185 186 187 188 | |
validate_item_id(v)
classmethod
Validate that item_id is not None.
Source code in uaef/hitl/models.py
155 156 157 158 159 160 161 | |
validate_reviewed_at(v, info)
classmethod
Validate that reviewed_at is set only when status is completed.
Source code in uaef/hitl/models.py
190 191 192 193 194 195 196 197 198 | |
validate_reviewer_id(v)
classmethod
Validate that reviewer_id is not empty if provided.
Source code in uaef/hitl/models.py
200 201 202 203 204 205 206 | |
add_to_review_queue(item_type, content, confidence_score, llm_scores=None, metadata=None)
Add an item to the human review queue.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item_type
|
Union[ItemType, str]
|
Type of item ("llm_evaluation", "agent_response", "simulated_conversation") |
required |
content
|
Dict[str, Any]
|
Item content (question, response, context, etc.) |
required |
confidence_score
|
float
|
Confidence score (0-1) for automatic priority assignment |
required |
llm_scores
|
Optional[Dict[str, float]]
|
Optional LLM-generated scores |
None
|
metadata
|
Optional[Dict[str, Any]]
|
Optional additional metadata |
None
|
Returns:
| Type | Description |
|---|---|
ReviewItem
|
Created ReviewItem with assigned priority |
Examples:
Add LLM evaluation for review: >>> item = add_to_review_queue( ... item_type="llm_evaluation", ... content={ ... "question": "What is AI?", ... "response": "AI is artificial intelligence...", ... "context": ["AI definition document"] ... }, ... confidence_score=0.65, ... llm_scores={"answer_relevance": 0.75} ... ) >>> print(f"Priority: {item.priority}")
Add agent response for review: >>> item = add_to_review_queue( ... item_type="agent_response", ... content={"response": "Here's your answer..."}, ... confidence_score=0.45 # Low confidence -> high priority ... )
Source code in uaef/api/__init__.py
851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 | |
batch_evaluate(traces, ground_truths=None, adapter=None, metrics=None, metric_set=None, max_workers=4, persist=False, experiment_name=None, experiment_objective=None, created_by=None, **kwargs)
Evaluate multiple agent traces in batch mode with parallel processing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
traces
|
List[Union[AgentTrace, Dict[str, Any]]]
|
List of agent traces to evaluate |
required |
ground_truths
|
Optional[List[Union[GroundTruth, Dict[str, Any]]]]
|
List of expected correct outputs (optional) |
None
|
adapter
|
Optional[str]
|
Framework adapter name. |
None
|
metrics
|
Optional[List[str]]
|
Flat list of metric names. Dimensions resolved automatically. |
None
|
metric_set
|
Optional[Dict[str, List[str]]]
|
Dict mapping dimension names to metric name lists. |
None
|
max_workers
|
int
|
Maximum number of parallel workers |
4
|
persist
|
bool
|
If True, creates a new experiment and persists all results. |
False
|
experiment_name
|
Optional[str]
|
Name for the new experiment (defaults to "default"). |
None
|
experiment_objective
|
Optional[str]
|
Description/objective for the experiment. |
None
|
created_by
|
Optional[str]
|
Security review H-02: identity (e.g. Cognito |
None
|
**kwargs
|
Additional evaluation parameters |
{}
|
Returns:
| Type | Description |
|---|---|
List[EvaluationResult]
|
List of EvaluationResult objects (with experiment_id when persist=True) |
Examples:
Batch evaluate and persist: >>> results = batch_evaluate( ... traces=[trace1, trace2, trace3], ... ground_truths=[gt1, gt2, gt3], ... persist=True, ... experiment_name="Batch Regression Test", ... )
Source code in uaef/api/__init__.py
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 | |
calculate_agreement(item_ids, include_inter_rater=True, include_llm_human=True)
Calculate agreement metrics for reviewed items.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item_ids
|
List[UUID]
|
List of item IDs to calculate agreement for |
required |
include_inter_rater
|
bool
|
Calculate inter-rater agreement between humans |
True
|
include_llm_human
|
bool
|
Calculate LLM-human correlation |
True
|
Returns:
| Type | Description |
|---|---|
AgreementMetrics
|
AgreementMetrics with correlation scores and statistics |
Examples:
Calculate agreement: >>> metrics = calculate_agreement( ... item_ids=[item1.item_id, item2.item_id, item3.item_id], ... include_inter_rater=True, ... include_llm_human=True ... ) >>> print(f"LLM-Human correlation: {metrics.llm_human_correlation:.2f}") >>> print(f"Inter-rater agreement: {metrics.inter_rater_agreement:.2f}")
Source code in uaef/api/__init__.py
954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 | |
compare_runs(baseline_run_id, new_run_id, threshold=5.0)
Compare two experiment runs to identify regressions and improvements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
baseline_run_id
|
UUID
|
ID of the baseline run |
required |
new_run_id
|
UUID
|
ID of the new run to compare |
required |
threshold
|
float
|
Percentage threshold for detecting changes (default: 5.0%) |
5.0
|
Returns:
| Type | Description |
|---|---|
ComparisonReport
|
ComparisonReport with detailed comparison results |
Raises:
| Type | Description |
|---|---|
ValueError
|
If run IDs don't exist |
Examples:
Compare two runs: >>> comparison = compare_runs( ... baseline_run_id=run1.run_id, ... new_run_id=run2.run_id, ... threshold=5.0 ... ) >>> print(f"Regressions: {comparison.regressions}") >>> print(f"Improvements: {comparison.improvements}") >>> >>> # Print detailed comparison >>> for mc in comparison.metric_comparisons: ... print(f"{mc.metric_name}: {mc.baseline_score:.2f} → {mc.current_score:.2f}")
Source code in uaef/api/__init__.py
657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 | |
create_experiment(name, description=None, metadata=None)
Create a new experiment for tracking agent evaluations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Human-readable experiment name |
required |
description
|
Optional[str]
|
Detailed description of the experiment |
None
|
metadata
|
Optional[Dict[str, Any]]
|
Additional metadata (tags, owner, project, etc.) |
None
|
Returns:
| Type | Description |
|---|---|
Experiment
|
Created Experiment instance |
Examples:
Create a simple experiment: >>> experiment = create_experiment( ... name="Customer Support Agent v2", ... description="Testing improved tool selection" ... ) >>> print(f"Experiment ID: {experiment.experiment_id}")
Create with metadata: >>> experiment = create_experiment( ... name="Production Agent", ... description="Final production version", ... metadata={"owner": "ml-team", "tags": ["production", "v2"]} ... )
Source code in uaef/api/__init__.py
506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 | |
create_run(experiment_id, run_name, agent_design, config=None, git_commit=None, metadata=None)
Create a new run within an experiment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
experiment_id
|
UUID
|
ID of the parent experiment |
required |
run_name
|
str
|
Human-readable name for this run |
required |
agent_design
|
Union[AgentDesign, Dict[str, Any]]
|
Complete agent design configuration (AgentDesign or dict) |
required |
config
|
Optional[Dict[str, Any]]
|
Full configuration snapshot for reproducibility |
None
|
git_commit
|
Optional[str]
|
Git commit hash for code versioning |
None
|
metadata
|
Optional[Dict[str, Any]]
|
Additional run metadata |
None
|
Returns:
| Type | Description |
|---|---|
ExperimentRun
|
Created ExperimentRun instance |
Raises:
| Type | Description |
|---|---|
ValueError
|
If experiment_id doesn't exist |
Examples:
Create a run with dict config: >>> run = create_run( ... experiment_id=experiment.experiment_id, ... run_name="baseline-v1", ... agent_design={ ... "framework": "langgraph", ... "model": "us.anthropic.claude-sonnet-4-6", ... "tools": ["search", "calculator"] ... }, ... config={"metric_set": ["tool_accuracy"]}, ... git_commit="a1b2c3d4" ... )
Create with AgentDesign object: >>> design = AgentDesign( ... framework="bedrock", ... model="us.anthropic.claude-sonnet-4-6", ... tools=["search"] ... ) >>> run = create_run( ... experiment_id=experiment.experiment_id, ... run_name="improved-v2", ... agent_design=design ... )
Source code in uaef/api/__init__.py
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 | |
detect_regressions(baseline_run_id, new_run_id, threshold=5.0)
Detect regressions between two experiment runs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
baseline_run_id
|
UUID
|
ID of the baseline run |
required |
new_run_id
|
UUID
|
ID of the new run to check |
required |
threshold
|
float
|
Percentage threshold for regression detection (default: 5.0%) |
5.0
|
Returns:
| Type | Description |
|---|---|
RegressionReport
|
RegressionReport with detected regressions and severity |
Examples:
Detect regressions: >>> report = detect_regressions( ... baseline_run_id=run1.run_id, ... new_run_id=run2.run_id, ... threshold=5.0 ... ) >>> if report.has_regressions: ... print(f"Found {len(report.regressions)} regressions!") ... for reg in report.regressions: ... print(f" {reg.metric_name}: {reg.severity}")
Source code in uaef/api/__init__.py
710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 | |
evaluate(trace, ground_truth=None, adapter=None, metrics=None, metric_set=None, dimension_weights=None, thresholds=None, context=None, persist=False, experiment_name=None, experiment_objective=None, created_by=None, **kwargs)
Evaluate an agent trace with automatic evaluator selection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace
|
Union[AgentTrace, MultiAgentTrace, Dict[str, Any]]
|
Agent trace to evaluate (AgentTrace, MultiAgentTrace, or raw output) |
required |
ground_truth
|
Optional[Union[GroundTruth, Dict[str, Any]]]
|
Expected correct outputs (optional) |
None
|
adapter
|
Optional[str]
|
Framework adapter name ("langgraph", "bedrock", etc.) |
None
|
metrics
|
Optional[List[str]]
|
Flat list of metric names. Dimensions resolved automatically. |
None
|
metric_set
|
Optional[Dict[str, List[str]]]
|
Dict mapping dimension names to metric name lists. |
None
|
dimension_weights
|
Optional[Dict[str, float]]
|
Weights for each dimension (uses defaults if None) |
None
|
thresholds
|
Optional[Dict[str, float]]
|
Threshold values for pass/fail (uses defaults if None) |
None
|
context
|
Optional[List[str]]
|
List of context documents (optional) |
None
|
persist
|
bool
|
If True, creates a new experiment and persists to DynamoDB + S3. |
False
|
experiment_name
|
Optional[str]
|
Name for the new experiment (defaults to "default"). |
None
|
experiment_objective
|
Optional[str]
|
Description/objective for the experiment. |
None
|
created_by
|
Optional[str]
|
Security review H-02: identity (e.g. Cognito |
None
|
**kwargs
|
Additional evaluation parameters |
{}
|
Returns:
| Type | Description |
|---|---|
EvaluationResult
|
EvaluationResult with experiment_id populated when persist=True. |
Examples:
Ephemeral (no persistence): >>> result = evaluate(trace=trace, ground_truth=gt)
Persisted: >>> result = evaluate( ... trace=trace, ... persist=True, ... experiment_name="Customer Support Agent v2", ... experiment_objective="Measure quality after prompt changes", ... )
Source code in uaef/api/__init__.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | |
generate_conversation(scenario_config, user_model, agent_config, max_turns=10)
Generate a simulated conversation (PLACEHOLDER).
NOTE: This is a placeholder implementation. Full conversation simulation will be implemented in future work.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario_config
|
Dict[str, Any]
|
Scenario configuration (domain, goal, success criteria) |
required |
user_model
|
Dict[str, Any]
|
User behavior model (personality, patience, knowledge) |
required |
agent_config
|
Dict[str, Any]
|
Agent configuration (framework, model, tools) |
required |
max_turns
|
int
|
Maximum number of conversation turns |
10
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Generated conversation with messages and metadata |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
This feature is not yet implemented |
Examples:
Generate conversation (future): >>> conversation = generate_conversation( ... scenario_config={ ... "domain": "customer_support", ... "user_goal": "Get refund", ... "success_criteria": ["Refund approved"] ... }, ... user_model={ ... "personality": "frustrated", ... "patience_level": 3 ... }, ... agent_config={ ... "framework": "langgraph", ... "model": "claude-3-sonnet" ... }, ... max_turns=10 ... )
Source code in uaef/api/__init__.py
762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 | |
get_full_metric_catalog()
Return every available metric name grouped by dimension/integration.
This is the single source of truth for the metric catalog presented by the demo backend and the UAEF service. It merges two registries:
- The built-in metric registry, grouped by dimension (e.g. "Response
Quality", "Tool Calling"), via :func:
list_metrics_by_dimension. - The external integrations registry, grouped by integration name (e.g.
"ragas", "deepeval"), via the integrations registry's
list_all_metrics().
Integration groups are included only when their optional extra is installed. If an integration extra is not installed, that integration's group is omitted from the returned catalog without raising (Requirement 12.8). Callers must not hardcode metric-name lists (Requirement 12.6).
Returns:
| Type | Description |
|---|---|
Dict[str, List[str]]
|
Dict mapping each dimension or integration group name to a sorted |
Dict[str, List[str]]
|
list of the metric names available in that group. |
Source code in uaef/metrics/__init__.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
get_run_evaluations(run_id)
Get all evaluation results for a run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run_id
|
UUID
|
ID of the run |
required |
Returns:
| Type | Description |
|---|---|
List[EvaluationResult]
|
List of EvaluationResult instances for the run |
Raises:
| Type | Description |
|---|---|
ValueError
|
If run doesn't exist |
Examples:
Get evaluations for a run: >>> evaluations = get_run_evaluations(run.run_id) >>> print(f"Found {len(evaluations)} evaluations")
Source code in uaef/api/__init__.py
635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 | |
record_evaluation(run_id, evaluation_result)
Record an evaluation result for a run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run_id
|
UUID
|
ID of the run |
required |
evaluation_result
|
EvaluationResult
|
Evaluation result to record |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If run_id doesn't exist |
Examples:
Record evaluation result: >>> result = evaluate(trace, ground_truth, adapter="langgraph") >>> record_evaluation(run.run_id, result)
Source code in uaef/api/__init__.py
612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 | |
run_scenario(scenario_id, agent_config, parameters=None)
Run a predefined scenario (PLACEHOLDER).
NOTE: This is a placeholder implementation. Full scenario execution will be implemented in future work.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario_id
|
str
|
ID of the predefined scenario |
required |
agent_config
|
Dict[str, Any]
|
Agent configuration |
required |
parameters
|
Optional[Dict[str, Any]]
|
Optional scenario parameters |
None
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Scenario execution results |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
This feature is not yet implemented |
Examples:
Run scenario (future): >>> result = run_scenario( ... scenario_id="customer_support_refund", ... agent_config={"framework": "langgraph", "model": "gpt-4"} ... )
Source code in uaef/api/__init__.py
811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 | |
submit_review(item_id, human_scores, reviewer_id, feedback=None)
Submit a human review for an item in the queue.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item_id
|
UUID
|
UUID of the item to review |
required |
human_scores
|
Dict[str, float]
|
Dictionary of metric_name -> score (0-1) |
required |
reviewer_id
|
str
|
ID of the human reviewer |
required |
feedback
|
Optional[str]
|
Optional textual feedback |
None
|
Returns:
| Type | Description |
|---|---|
ReviewItem
|
Updated ReviewItem with completed status |
Raises:
| Type | Description |
|---|---|
ValueError
|
If item not found or already completed |
Examples:
Submit review: >>> reviewed = submit_review( ... item_id=item.item_id, ... human_scores={ ... "answer_relevance": 0.85, ... "answer_correctness": 0.90 ... }, ... reviewer_id="reviewer_123", ... feedback="Good response but could be more detailed" ... ) >>> print(f"Status: {reviewed.status}")
Source code in uaef/api/__init__.py
911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 | |
uaef.evaluation.base_evaluator
Base evaluator interface for UAEF.
This module provides the abstract base class for all evaluators, defining the core evaluation interface and common functionality.
BaseEvaluator
Bases: ABC
Abstract base class for all evaluators.
Provides common functionality for: - Single evaluation - Batch evaluation - Parallel metric calculation - Async support for LLM-based metrics
Source code in uaef/evaluation/base_evaluator.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 | |
aggregate_dimension_scores(metric_scores, dimension_weights=None)
Aggregate metric scores by dimension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metric_scores
|
List[MetricScore]
|
List of metric scores to aggregate |
required |
dimension_weights
|
Optional[Dict[str, float]]
|
Optional weights for each dimension |
None
|
Returns:
| Type | Description |
|---|---|
List[DimensionResult]
|
List of DimensionResult objects |
Source code in uaef/evaluation/base_evaluator.py
864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 | |
batch_evaluate(traces, ground_truths=None, metric_set=None, **kwargs)
Evaluate multiple traces in batch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
traces
|
List[any]
|
List of agent traces to evaluate |
required |
ground_truths
|
Optional[List[Optional[GroundTruth]]]
|
List of ground truths (optional, can be None for each) |
None
|
metric_set
|
Optional[Dict[str, List[str]]]
|
Dictionary mapping dimension names to lists of metric names |
None
|
**kwargs
|
Additional evaluation parameters |
{}
|
Returns:
| Type | Description |
|---|---|
List[EvaluationResult]
|
List of EvaluationResult objects |
Raises:
| Type | Description |
|---|---|
ValueError
|
If inputs are invalid |
Source code in uaef/evaluation/base_evaluator.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
calculate_metrics_parallel(metrics, evaluation_input)
Calculate multiple metrics in parallel.
Separates deterministic and LLM-based metrics, running deterministic metrics in parallel threads and LLM-based metrics asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metrics
|
List[BaseMetric]
|
List of metric instances to calculate |
required |
evaluation_input
|
EvaluationInput
|
Input data for evaluation |
required |
Returns:
| Type | Description |
|---|---|
List[MetricScore]
|
List of MetricScore objects |
Source code in uaef/evaluation/base_evaluator.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 | |
calculate_metrics_with_dependencies(metrics, evaluation_input)
Calculate metrics respecting dependencies.
Simple two-phase approach: - Phase 1: Calculate metrics with no dependencies - Phase 2: Calculate metrics with dependencies (which can now read metadata)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metrics
|
List[BaseMetric]
|
List of metric instances to calculate |
required |
evaluation_input
|
EvaluationInput
|
Input data for evaluation |
required |
Returns:
| Type | Description |
|---|---|
List[MetricScore]
|
List of MetricScore objects for all metrics |
Source code in uaef/evaluation/base_evaluator.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
calculate_overall_score(dimension_results)
Calculate overall score from dimension results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dimension_results
|
List[DimensionResult]
|
List of dimension results |
required |
Returns:
| Type | Description |
|---|---|
float
|
Overall weighted score (0-1) |
Source code in uaef/evaluation/base_evaluator.py
934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 | |
check_thresholds(dimension_results, thresholds=None)
Check if dimension scores meet thresholds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dimension_results
|
List[DimensionResult]
|
List of dimension results |
required |
thresholds
|
Optional[Dict[str, float]]
|
Dictionary mapping dimension names to threshold values |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
Tuple of (passed, failures) where passed is True if all thresholds met, |
List[str]
|
and failures is a list of failure messages |
Source code in uaef/evaluation/base_evaluator.py
967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 | |
evaluate(trace, ground_truth=None, metric_set=None, **kwargs)
abstractmethod
Evaluate a single trace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace
|
any
|
Agent trace to evaluate |
required |
ground_truth
|
Optional[GroundTruth]
|
Expected correct outputs (optional) |
None
|
metric_set
|
Optional[Dict[str, List[str]]]
|
Dictionary mapping dimension names to lists of metric names |
None
|
**kwargs
|
Additional evaluation parameters |
{}
|
Returns:
| Type | Description |
|---|---|
EvaluationResult
|
EvaluationResult with scores and metadata |
Raises:
| Type | Description |
|---|---|
ValueError
|
If inputs are invalid |
RuntimeError
|
If evaluation fails |
Source code in uaef/evaluation/base_evaluator.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
uaef.evaluation.single_agent
Single-agent evaluator for UAEF.
This module provides evaluation functionality for single-agent traces, coordinating the adapter → metrics → LLM judge flow.
SingleAgentEvaluator
Bases: BaseEvaluator
Evaluator for single-agent traces.
Coordinates the complete evaluation flow: 1. Create EvaluationInput from trace and ground truth 2. Calculate metrics for each dimension 3. Aggregate dimension scores with weighted averages 4. Calculate overall score 5. Check thresholds and identify failures
Source code in uaef/evaluation/single_agent.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | |
evaluate(trace, ground_truth=None, metric_set=None, dimension_weights=None, thresholds=None, context=None, **kwargs)
Evaluate a single agent trace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace
|
AgentTrace
|
Agent trace to evaluate |
required |
ground_truth
|
Optional[GroundTruth]
|
Expected correct outputs (optional) |
None
|
metric_set
|
Optional[Dict[str, List[str]]]
|
Dictionary mapping dimension names to lists of metric names. If None, uses all available metrics. |
None
|
dimension_weights
|
Optional[Dict[str, float]]
|
Weights for each dimension (uses defaults if None) |
None
|
thresholds
|
Optional[Dict[str, float]]
|
Threshold values for pass/fail (uses defaults if None) |
None
|
context
|
Optional[List[str]]
|
List of context documents (optional) |
None
|
**kwargs
|
Additional evaluation parameters |
{}
|
Returns:
| Type | Description |
|---|---|
EvaluationResult
|
EvaluationResult with scores and metadata |
Raises:
| Type | Description |
|---|---|
ValueError
|
If inputs are invalid |
RuntimeError
|
If evaluation fails |
Source code in uaef/evaluation/single_agent.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
evaluate_multi_turn(per_turn_traces, full_trace, ground_truth=None, metric_set=None, dimension_weights=None, thresholds=None, context=None, **kwargs)
Evaluate a single-agent multi-turn conversation from pre-split per-turn traces.
Both per_turn_traces and full_trace must be AgentTrace instances. Multi-agent traces are handled by MultiAgentEvaluator.evaluate_multi_turn().
Flow:
1. Iterate per_turn_traces, run per-turn-eligible metrics on each
(using ground_truth.expected_arguments["per_turn_expected"][i] and
["per_turn_tools"][i] for that turn's ground truth)
2. Average per-turn scores across turns
3. Run full-trace-only metrics (multi-turn + throughput) on full_trace
4. Combine and return EvaluationResult with per-turn breakdown in metadata
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
per_turn_traces
|
List[AgentTrace]
|
List of per-turn AgentTraces (one per user turn) |
required |
full_trace
|
AgentTrace
|
AgentTrace covering the entire conversation |
required |
ground_truth
|
Optional[GroundTruth]
|
Expected correct outputs (optional). May contain per_turn_expected and per_turn_tools arrays in expected_arguments. |
None
|
metric_set
|
Optional[Dict[str, List[str]]]
|
Dictionary mapping dimension names to lists of metric names |
None
|
dimension_weights
|
Optional[Dict[str, float]]
|
Weights for each dimension (uses defaults if None) |
None
|
thresholds
|
Optional[Dict[str, float]]
|
Threshold values for pass/fail (uses defaults if None) |
None
|
context
|
Optional[List[str]]
|
List of context documents (optional) |
None
|
**kwargs
|
Additional evaluation parameters |
{}
|
Returns:
| Type | Description |
|---|---|
EvaluationResult
|
EvaluationResult with scores and metadata (including per_turn breakdown) |
Source code in uaef/evaluation/single_agent.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | |
evaluate_trace(trace, ground_truth=None, metric_set=None, **kwargs)
Alias for evaluate() method for backward compatibility.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace
|
AgentTrace
|
Agent trace to evaluate |
required |
ground_truth
|
Optional[GroundTruth]
|
Expected correct outputs (optional) |
None
|
metric_set
|
Optional[Dict[str, List[str]]]
|
Dictionary mapping dimension names to lists of metric names |
None
|
**kwargs
|
Additional evaluation parameters |
{}
|
Returns:
| Type | Description |
|---|---|
EvaluationResult
|
EvaluationResult with scores and metadata |
Source code in uaef/evaluation/single_agent.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
evaluate_with_custom_metrics(trace, metrics, ground_truth=None, dimension_weights=None, thresholds=None, **kwargs)
Evaluate a trace with a custom list of metrics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace
|
AgentTrace
|
Agent trace to evaluate |
required |
metrics
|
List[str]
|
List of metric names to calculate |
required |
ground_truth
|
Optional[GroundTruth]
|
Expected correct outputs (optional) |
None
|
dimension_weights
|
Optional[Dict[str, float]]
|
Weights for each dimension (uses defaults if None) |
None
|
thresholds
|
Optional[Dict[str, float]]
|
Threshold values for pass/fail (uses defaults if None) |
None
|
**kwargs
|
Additional evaluation parameters |
{}
|
Returns:
| Type | Description |
|---|---|
EvaluationResult
|
EvaluationResult with scores and metadata |
Source code in uaef/evaluation/single_agent.py
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | |
uaef.evaluation.multi_turn
Multi-turn conversation evaluator for UAEF.
This module provides evaluation functionality for multi-turn conversations, assessing context retention, coherence, and goal achievement across turns.
MultiTurnEvaluator
Bases: BaseEvaluator
Evaluator for multi-turn conversations.
Specializes in evaluating: - Context retention across turns - Coherence and logical flow - Conversation completeness and goal achievement - Turn efficiency
Requirements: 10.1-10.6
Source code in uaef/evaluation/multi_turn.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 | |
evaluate(trace, ground_truth=None, metric_set=None, dimension_weights=None, thresholds=None, context=None, **kwargs)
Evaluate a multi-turn conversation from an AgentTrace.
This is an alternative interface that accepts an AgentTrace directly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace
|
AgentTrace
|
Agent trace containing conversation messages |
required |
ground_truth
|
Optional[GroundTruth]
|
Expected correct outputs (optional) |
None
|
metric_set
|
Optional[Dict[str, List[str]]]
|
Dictionary mapping dimension names to lists of metric names |
None
|
dimension_weights
|
Optional[Dict[str, float]]
|
Weights for each dimension (uses defaults if None) |
None
|
thresholds
|
Optional[Dict[str, float]]
|
Threshold values for pass/fail (uses defaults if None) |
None
|
context
|
Optional[List[str]]
|
List of context documents (optional) |
None
|
**kwargs
|
Additional evaluation parameters (can include 'goal') |
{}
|
Returns:
| Type | Description |
|---|---|
EvaluationResult
|
EvaluationResult with scores and metadata |
Source code in uaef/evaluation/multi_turn.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
evaluate_coherence(messages)
Evaluate coherence and logical flow of conversation.
Requirement 10.2: Evaluate coherence by checking logical flow and consistency
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
messages
|
List[Message]
|
List of conversation messages |
required |
Returns:
| Type | Description |
|---|---|
MetricScore
|
MetricScore for coherence |
Source code in uaef/evaluation/multi_turn.py
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 | |
evaluate_context_retention(messages, ground_truth=None)
Evaluate context retention across conversation turns.
Requirement 10.1: Assess context retention across turns Requirement 10.4: Verify information from earlier turns is used appropriately
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
messages
|
List[Message]
|
List of conversation messages |
required |
ground_truth
|
Optional[GroundTruth]
|
Expected correct outputs (optional) |
None
|
Returns:
| Type | Description |
|---|---|
MetricScore
|
MetricScore for context retention |
Source code in uaef/evaluation/multi_turn.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | |
evaluate_conversation(messages, goal=None, ground_truth=None, metric_set=None, dimension_weights=None, thresholds=None, context=None, **kwargs)
Evaluate a multi-turn conversation.
Requirements: - 10.1: Assess context retention across turns - 10.2: Evaluate coherence by checking logical flow - 10.3: Evaluate conversation completeness - 10.4: Verify information from earlier turns is used appropriately - 10.5: Support goal-based evaluation - 10.6: Identify which success criteria were not met
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
messages
|
List[Message]
|
List of conversation messages |
required |
goal
|
Optional[str]
|
User goal for the conversation (optional) |
None
|
ground_truth
|
Optional[GroundTruth]
|
Expected correct outputs (optional) |
None
|
metric_set
|
Optional[Dict[str, List[str]]]
|
Dictionary mapping dimension names to lists of metric names. If None, uses all multi-turn metrics. |
None
|
dimension_weights
|
Optional[Dict[str, float]]
|
Weights for each dimension (uses defaults if None) |
None
|
thresholds
|
Optional[Dict[str, float]]
|
Threshold values for pass/fail (uses defaults if None) |
None
|
context
|
Optional[List[str]]
|
List of context documents (optional) |
None
|
**kwargs
|
Additional evaluation parameters |
{}
|
Returns:
| Type | Description |
|---|---|
EvaluationResult
|
EvaluationResult with scores and metadata |
Raises:
| Type | Description |
|---|---|
ValueError
|
If inputs are invalid |
RuntimeError
|
If evaluation fails |
Source code in uaef/evaluation/multi_turn.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
uaef.evaluation.multi_agent
Multi-agent evaluator for UAEF.
This module provides evaluation functionality for multi-agent traces, coordinating metric calculation for multi-agent coordination scenarios.
MultiAgentEvaluator
Bases: BaseEvaluator
Evaluator for multi-agent traces.
Coordinates the complete evaluation flow for multi-agent coordination: 1. Create EvaluationInput from multi-agent trace and ground truth 2. Calculate metrics for each dimension (including multi-agent specific) 3. Aggregate dimension scores with weighted averages 4. Calculate overall score 5. Check thresholds and identify failures
Source code in uaef/evaluation/multi_agent.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | |
batch_evaluate(traces, ground_truths=None, metric_set=None, **kwargs)
Evaluate multiple multi-agent traces in batch.
Automatically calculates batch-level metrics for metrics that support it (e.g., agent_utilization_batch).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
traces
|
List[MultiAgentTrace]
|
List of multi-agent traces to evaluate |
required |
ground_truths
|
Optional[List[Optional[GroundTruth]]]
|
List of ground truths (optional, can be None for each) |
None
|
metric_set
|
Optional[Dict[str, List[str]]]
|
Dictionary mapping dimension names to lists of metric names |
None
|
**kwargs
|
Additional evaluation parameters |
{}
|
Returns:
| Type | Description |
|---|---|
List[EvaluationResult]
|
List of EvaluationResult objects, with batch metrics in results[0].metadata |
Raises:
| Type | Description |
|---|---|
ValueError
|
If inputs are invalid |
Source code in uaef/evaluation/multi_agent.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 | |
evaluate(trace, ground_truth=None, metric_set=None, dimension_weights=None, thresholds=None, context=None, **kwargs)
Evaluate a multi-agent trace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace
|
MultiAgentTrace
|
Multi-agent trace to evaluate |
required |
ground_truth
|
Optional[GroundTruth]
|
Expected correct outputs (optional) |
None
|
metric_set
|
Optional[Dict[str, List[str]]]
|
Dictionary mapping dimension names to lists of metric names. If None, uses all available metrics. |
None
|
dimension_weights
|
Optional[Dict[str, float]]
|
Weights for each dimension (uses defaults if None) |
None
|
thresholds
|
Optional[Dict[str, float]]
|
Threshold values for pass/fail (uses defaults if None) |
None
|
context
|
Optional[List[str]]
|
List of context documents (optional) |
None
|
**kwargs
|
Additional evaluation parameters |
{}
|
Returns:
| Type | Description |
|---|---|
EvaluationResult
|
EvaluationResult with scores and metadata |
Raises:
| Type | Description |
|---|---|
ValueError
|
If inputs are invalid |
RuntimeError
|
If evaluation fails |
Source code in uaef/evaluation/multi_agent.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
evaluate_multi_turn(per_turn_traces, full_trace, ground_truth=None, metric_set=None, dimension_weights=None, thresholds=None, context=None, **kwargs)
Evaluate a multi-agent multi-turn conversation from pre-split per-turn traces.
Both per_turn_traces and full_trace must be MultiAgentTrace instances. Single-agent (AgentTrace) inputs are handled by SingleAgentEvaluator.evaluate_multi_turn().
Per-turn metrics (tool calling, response quality, multi-agent, ...)
run on each MultiAgentTrace turn and are averaged. Full-trace metrics
(context_retention, coherence, ...) run on the full MultiAgentTrace,
whose messages property aggregates sub-agent messages in order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
per_turn_traces
|
List[MultiAgentTrace]
|
List of per-turn MultiAgentTraces (one per user turn) |
required |
full_trace
|
MultiAgentTrace
|
MultiAgentTrace covering the entire conversation |
required |
ground_truth
|
Optional[GroundTruth]
|
Expected correct outputs (optional). May contain per_turn_expected and per_turn_tools arrays in expected_arguments. |
None
|
metric_set
|
Optional[Dict[str, List[str]]]
|
Dictionary mapping dimension names to lists of metric names |
None
|
dimension_weights
|
Optional[Dict[str, float]]
|
Weights for each dimension (uses defaults if None) |
None
|
thresholds
|
Optional[Dict[str, float]]
|
Threshold values for pass/fail (uses defaults if None) |
None
|
context
|
Optional[List[str]]
|
List of context documents (optional) |
None
|
**kwargs
|
Additional evaluation parameters |
{}
|
Returns:
| Type | Description |
|---|---|
EvaluationResult
|
EvaluationResult with per-turn breakdown in metadata |
Source code in uaef/evaluation/multi_agent.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | |
uaef.evaluation.online
Online evaluation mode for UAEF.
This module provides real-time evaluation functionality with: - Fast deterministic metrics (< 500ms) - Async LLM-based metrics (non-blocking) - Partial results for immediate decisions - Background storage of complete results
OnlineEvaluator
Bases: BaseEvaluator
Evaluator for online/real-time evaluation.
Optimized for low-latency evaluation with: - Synchronous calculation of fast deterministic metrics - Asynchronous execution of LLM-based metrics - Immediate return of partial results - Background completion and storage - Threshold-based pass/fail decisions
Source code in uaef/evaluation/online.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 | |
aggregate_session_metrics(turn_results, session_id=None)
Aggregate metrics across all turns in a conversation session.
This method combines per-turn evaluation results into session-level metrics, providing an overall assessment of the entire conversation including: - Average scores across all turns - Context retention across the conversation - Overall coherence and goal achievement - Aggregated performance metrics
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
turn_results
|
List[EvaluationResult]
|
List of EvaluationResult objects, one per turn |
required |
session_id
|
Optional[str]
|
Optional session identifier |
None
|
Returns:
| Type | Description |
|---|---|
EvaluationResult
|
EvaluationResult with aggregated session-level metrics |
Example
evaluator = OnlineEvaluator() turn_results = []
Evaluate each turn
for turn_trace in conversation_turns: result = evaluator.evaluate(turn_trace) turn_results.append(result)
Get session-level aggregation
session_result = evaluator.aggregate_session_metrics(turn_results) print(f"Overall conversation score: {session_result.overall_score:.3f}")
Source code in uaef/evaluation/online.py
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 | |
evaluate(trace, ground_truth=None, metric_set=None, thresholds=None, context=None, **kwargs)
Evaluate a trace in online mode (blocking until complete).
This method blocks until all metrics are calculated. For non-blocking evaluation, use evaluate_response() instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace
|
AgentTrace
|
Agent trace to evaluate |
required |
ground_truth
|
Optional[GroundTruth]
|
Expected correct outputs (optional) |
None
|
metric_set
|
Optional[Dict[str, List[str]]]
|
Dictionary mapping dimension names to lists of metric names |
None
|
thresholds
|
Optional[Dict[str, float]]
|
Threshold values for pass/fail (uses defaults if None) |
None
|
context
|
Optional[List[str]]
|
List of context documents (optional) |
None
|
**kwargs
|
Additional evaluation parameters |
{}
|
Returns:
| Type | Description |
|---|---|
EvaluationResult
|
Complete EvaluationResult |
Source code in uaef/evaluation/online.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |
evaluate_response(trace, ground_truth=None, metric_set=None, thresholds=None, context=None, store_async=True, **kwargs)
Evaluate a response in online mode (non-blocking).
Returns partial results immediately with deterministic metrics, and starts async calculation of LLM-based metrics in background.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace
|
AgentTrace
|
Agent trace to evaluate |
required |
ground_truth
|
Optional[GroundTruth]
|
Expected correct outputs (optional) |
None
|
metric_set
|
Optional[Dict[str, List[str]]]
|
Dictionary mapping dimension names to lists of metric names. If None, uses subset of metrics suitable for online evaluation. |
None
|
thresholds
|
Optional[Dict[str, float]]
|
Threshold values for pass/fail (uses defaults if None) |
None
|
context
|
Optional[List[str]]
|
List of context documents (optional) |
None
|
store_async
|
bool
|
If True, store complete results in background |
True
|
**kwargs
|
Additional evaluation parameters |
{}
|
Returns:
| Type | Description |
|---|---|
PartialEvaluationResult
|
Tuple of (PartialEvaluationResult, Optional[asyncio.Task]) |
Optional[Task]
|
The task completes when all LLM metrics are calculated. |
Source code in uaef/evaluation/online.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | |
get_stored_result(trace_id)
Retrieve a stored result by trace ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace_id
|
str
|
Trace ID to look up |
required |
Returns:
| Type | Description |
|---|---|
Optional[EvaluationResult]
|
EvaluationResult if found, None otherwise |
Source code in uaef/evaluation/online.py
512 513 514 515 516 517 518 519 520 521 522 | |
PartialEvaluationResult
Partial evaluation result for online mode.
Contains immediately available deterministic metrics and placeholders for async LLM-based metrics that are still being calculated.
Source code in uaef/evaluation/online.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
to_dict()
Convert to dictionary representation.
Source code in uaef/evaluation/online.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
uaef.evaluation.offline
Offline batch evaluation mode for UAEF.
This module provides batch evaluation functionality with: - Parallel processing of multiple traces - Batch LLM API calls for efficiency - Aggregate statistics across batch - Configurable parallelism - Graceful error handling - Export to various formats
BatchStatistics
Aggregate statistics for a batch evaluation.
Source code in uaef/evaluation/offline.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
to_dict()
Convert to dictionary representation.
Source code in uaef/evaluation/offline.py
112 113 114 115 116 117 118 119 120 121 122 123 124 | |
OfflineEvaluator
Bases: BaseEvaluator
Evaluator for offline/batch evaluation.
Optimized for throughput and efficiency with: - Parallel processing of multiple traces - Batch LLM API calls - Aggregate statistics calculation - Configurable parallelism - Graceful error handling - Export to various formats
Source code in uaef/evaluation/offline.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 | |
batch_evaluate(traces, ground_truths=None, metric_set=None, dimension_weights=None, thresholds=None, contexts=None, **kwargs)
Evaluate multiple traces in parallel with batch optimization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
traces
|
List[AgentTrace]
|
List of agent traces to evaluate |
required |
ground_truths
|
Optional[List[Optional[GroundTruth]]]
|
List of ground truths (optional) |
None
|
metric_set
|
Optional[Dict[str, List[str]]]
|
Dictionary mapping dimension names to lists of metric names |
None
|
dimension_weights
|
Optional[Dict[str, float]]
|
Weights for each dimension (uses defaults if None) |
None
|
thresholds
|
Optional[Dict[str, float]]
|
Threshold values for pass/fail (uses defaults if None) |
None
|
contexts
|
Optional[List[Optional[List[str]]]]
|
List of context documents for each trace (optional) |
None
|
**kwargs
|
Additional evaluation parameters |
{}
|
Returns:
| Type | Description |
|---|---|
List[EvaluationResult]
|
List of EvaluationResult objects |
Source code in uaef/evaluation/offline.py
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 | |
evaluate(trace, ground_truth=None, metric_set=None, dimension_weights=None, thresholds=None, context=None, **kwargs)
Evaluate a single trace (delegates to batch_evaluate).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace
|
AgentTrace
|
Agent trace to evaluate |
required |
ground_truth
|
Optional[GroundTruth]
|
Expected correct outputs (optional) |
None
|
metric_set
|
Optional[Dict[str, List[str]]]
|
Dictionary mapping dimension names to lists of metric names |
None
|
dimension_weights
|
Optional[Dict[str, float]]
|
Weights for each dimension (uses defaults if None) |
None
|
thresholds
|
Optional[Dict[str, float]]
|
Threshold values for pass/fail (uses defaults if None) |
None
|
context
|
Optional[List[str]]
|
List of context documents (optional) |
None
|
**kwargs
|
Additional evaluation parameters |
{}
|
Returns:
| Type | Description |
|---|---|
EvaluationResult
|
EvaluationResult with scores and metadata |
Source code in uaef/evaluation/offline.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
evaluate_dataset(dataset, metric_set=None, dimension_weights=None, thresholds=None, contexts=None, **kwargs)
Evaluate a complete dataset of traces.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
List[Tuple[AgentTrace, Optional[GroundTruth]]]
|
List of (trace, ground_truth) tuples |
required |
metric_set
|
Optional[Dict[str, List[str]]]
|
Dictionary mapping dimension names to lists of metric names |
None
|
dimension_weights
|
Optional[Dict[str, float]]
|
Weights for each dimension (uses defaults if None) |
None
|
thresholds
|
Optional[Dict[str, float]]
|
Threshold values for pass/fail (uses defaults if None) |
None
|
contexts
|
Optional[List[Optional[List[str]]]]
|
List of context documents for each trace (optional) |
None
|
**kwargs
|
Additional evaluation parameters |
{}
|
Returns:
| Type | Description |
|---|---|
Tuple[List[EvaluationResult], BatchStatistics]
|
Tuple of (results, statistics) |
Source code in uaef/evaluation/offline.py
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | |
export_results(results, statistics, output_path, format='json')
Export evaluation results to file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
List[EvaluationResult]
|
List of evaluation results |
required |
statistics
|
Optional[BatchStatistics]
|
Batch statistics (optional) |
required |
output_path
|
str
|
Path to output file |
required |
format
|
str
|
Export format ("json", "csv", "html") |
'json'
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If format is not supported |
Source code in uaef/evaluation/offline.py
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 | |
uaef.config
Configuration management for UAEF.
AWSConfig
Bases: BaseModel
AWS configuration for Bedrock LLM Judge.
Source code in uaef/config.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
from_env()
classmethod
Load AWS configuration from environment variables.
Source code in uaef/config.py
34 35 36 37 38 39 40 41 42 | |
InsightConfig
Bases: BaseModel
Configuration for LLM-powered insight generation.
Defaults match LLMJudgeConfig but with slightly higher temperature for more natural prose output.
Source code in uaef/config.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
LLMJudgeConfig
Bases: BaseModel
Configuration for LLM Judge.
Source code in uaef/config.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
validate_model_id(v)
classmethod
Reject a judge model_id outside the vetted Anthropic Claude family.
Source code in uaef/config.py
120 121 122 123 124 | |
validate_temperature(v)
classmethod
Validate temperature is between 0 and 1.
Source code in uaef/config.py
112 113 114 115 116 117 118 | |
StorageConfig
Bases: BaseModel
Configuration for DynamoDB + S3 persistence.
Source code in uaef/config.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
from_env()
classmethod
Load storage configuration from environment variables.
Source code in uaef/config.py
185 186 187 188 189 190 191 192 193 | |
UAEFConfig
Bases: BaseModel
Main UAEF configuration.
Source code in uaef/config.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | |
from_env()
classmethod
Load configuration from environment variables.
Source code in uaef/config.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | |
from_file(config_path)
classmethod
Load configuration from a YAML or JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_path
|
Union[str, Path]
|
Path to configuration file |
required |
Returns:
| Type | Description |
|---|---|
UAEFConfig
|
UAEFConfig instance |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If config file doesn't exist |
ValueError
|
If config file format is invalid |
Source code in uaef/config.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | |
save_to_file(config_path)
Save configuration to a YAML or JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_path
|
Path
|
Path to save configuration file |
required |
Source code in uaef/config.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | |
to_dict()
Convert configuration to dictionary.
Source code in uaef/config.py
299 300 301 | |
validate_log_level(v)
classmethod
Validate log level is valid.
Source code in uaef/config.py
229 230 231 232 233 234 235 236 237 | |
get_config()
Get the global UAEF configuration.
Loads from environment variables on first call.
Returns:
| Type | Description |
|---|---|
UAEFConfig
|
UAEFConfig instance |
Source code in uaef/config.py
329 330 331 332 333 334 335 336 337 338 339 340 341 | |
reset_config()
Reset the global configuration to None.
Source code in uaef/config.py
355 356 357 358 | |
set_config(config)
Set the global UAEF configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
UAEFConfig
|
UAEFConfig instance to set as global |
required |
Source code in uaef/config.py
344 345 346 347 348 349 350 351 352 | |