Integrations
Connectors that expose RAGAS and DeepEval metrics through UAEF's metric interface. The metric names they add are listed in the Metrics Catalog.
uaef.integrations.registry
External metric connector registry and factory for managing external library integrations.
ExternalMetricConnector
Base interface for external metric connectors.
All external metric connectors should implement this interface to ensure consistent behavior and integration with UAEF.
Source code in uaef/integrations/registry.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 | |
calculate_metrics(evaluation_input, metric_names, **kwargs)
Calculate multiple metrics and return UAEF MetricScore objects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluation_input
|
EvaluationInput
|
UAEF evaluation input |
required |
metric_names
|
List[str]
|
List of metric names to calculate |
required |
**kwargs
|
Any
|
Additional connector-specific parameters |
{}
|
Returns:
| Type | Description |
|---|---|
List[MetricScore]
|
List of MetricScore objects |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If external library is not available |
Source code in uaef/integrations/registry.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
is_available()
Check if external library is available.
Returns:
| Type | Description |
|---|---|
bool
|
True if external library is installed and available, False otherwise |
Source code in uaef/integrations/registry.py
23 24 25 26 27 28 29 30 | |
list_available_metrics()
List all metrics supported by this connector.
Returns:
| Type | Description |
|---|---|
List[str]
|
List of metric names |
Source code in uaef/integrations/registry.py
54 55 56 57 58 59 60 61 | |
ExternalMetricRegistry
Registry for managing external metric library connectors.
This registry allows: - Registration of built-in connectors (RAGAS, DeepEval) - Registration of custom connectors - Retrieval of connectors by library name - Discovery of available connectors and their metrics - Graceful handling of unavailable libraries
Source code in uaef/integrations/registry.py
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 | |
calculate_metrics(connector_name, evaluation_input, metric_names, **kwargs)
Calculate metrics using a specific connector.
This is a convenience method that gets the connector and calls its calculate_metrics method. Handles errors gracefully per requirement 14.6.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
connector_name
|
str
|
Name of the connector to use |
required |
evaluation_input
|
EvaluationInput
|
UAEF evaluation input |
required |
metric_names
|
List[str]
|
List of metric names to calculate |
required |
**kwargs
|
Any
|
Additional connector-specific parameters |
{}
|
Returns:
| Type | Description |
|---|---|
List[MetricScore]
|
List of MetricScore objects (may be empty if connector unavailable) |
Source code in uaef/integrations/registry.py
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 | |
get_connector(name, connector_config=None)
Get a connector instance by library name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Library name (e.g., "ragas", "deepeval") |
required |
connector_config
|
Optional[Dict[str, Any]]
|
Optional configuration for connector initialization |
None
|
Returns:
| Type | Description |
|---|---|
ExternalMetricConnector
|
Connector instance |
Raises:
| Type | Description |
|---|---|
ValueError
|
If connector is not registered |
Source code in uaef/integrations/registry.py
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 | |
is_available(name)
Check if a connector is registered and its library is available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Library name |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if connector is registered and library is available, False otherwise |
Source code in uaef/integrations/registry.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
is_registered(name)
Check if a connector is registered.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Library name |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if connector is registered, False otherwise |
Source code in uaef/integrations/registry.py
220 221 222 223 224 225 226 227 228 229 230 | |
list_all_metrics()
List all metrics from all available connectors.
Returns:
| Type | Description |
|---|---|
Dict[str, List[str]]
|
Dictionary mapping connector name to list of metric names |
Source code in uaef/integrations/registry.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | |
list_available_connectors()
List connectors that are available (library is installed).
Returns:
| Type | Description |
|---|---|
List[str]
|
List of available connector names |
Source code in uaef/integrations/registry.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
list_connectors()
List all registered connector names.
Returns:
| Type | Description |
|---|---|
List[str]
|
List of connector names |
Source code in uaef/integrations/registry.py
177 178 179 180 181 182 183 184 | |
register(name, connector_class, override=False)
Register an external metric connector class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Library name (e.g., "ragas", "deepeval") |
required |
connector_class
|
Type[ExternalMetricConnector]
|
Connector class that implements ExternalMetricConnector interface |
required |
override
|
bool
|
If True, allow overriding existing connectors |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If connector is already registered and override is False |
TypeError
|
If connector_class does not implement required methods |
Source code in uaef/integrations/registry.py
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 | |
unregister(name)
Unregister a connector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Library name |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If connector is not registered |
Source code in uaef/integrations/registry.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | |
calculate_external_metrics(connector_name, evaluation_input, metric_names, **kwargs)
Calculate metrics using a specific connector from the global registry.
This is a convenience function that handles errors gracefully per requirement 14.6.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
connector_name
|
str
|
Name of the connector to use |
required |
evaluation_input
|
EvaluationInput
|
UAEF evaluation input |
required |
metric_names
|
List[str]
|
List of metric names to calculate |
required |
**kwargs
|
Any
|
Additional connector-specific parameters |
{}
|
Returns:
| Type | Description |
|---|---|
List[MetricScore]
|
List of MetricScore objects (may be empty if connector unavailable) |
Source code in uaef/integrations/registry.py
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 | |
get_connector(name, connector_config=None)
Get a connector instance from the global registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Library name (e.g., "ragas", "deepeval") |
required |
connector_config
|
Optional[Dict[str, Any]]
|
Optional configuration for connector initialization |
None
|
Returns:
| Type | Description |
|---|---|
ExternalMetricConnector
|
Connector instance |
Raises:
| Type | Description |
|---|---|
ValueError
|
If connector is not registered |
Source code in uaef/integrations/registry.py
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 | |
get_registry()
Get the global external metric registry instance.
Returns:
| Type | Description |
|---|---|
ExternalMetricRegistry
|
Global ExternalMetricRegistry instance |
Source code in uaef/integrations/registry.py
462 463 464 465 466 467 468 469 | |
is_connector_available(name)
Check if a connector is registered and its library is available in the global registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Library name |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if connector is registered and library is available, False otherwise |
Source code in uaef/integrations/registry.py
421 422 423 424 425 426 427 428 429 430 431 | |
is_connector_registered(name)
Check if a connector is registered in the global registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Library name |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if connector is registered, False otherwise |
Source code in uaef/integrations/registry.py
408 409 410 411 412 413 414 415 416 417 418 | |
list_all_metrics()
List all metrics from all available connectors in the global registry.
Returns:
| Type | Description |
|---|---|
Dict[str, List[str]]
|
Dictionary mapping connector name to list of metric names |
Source code in uaef/integrations/registry.py
398 399 400 401 402 403 404 405 | |
list_available_connectors()
List connectors that are available (library is installed) in the global registry.
Returns:
| Type | Description |
|---|---|
List[str]
|
List of available connector names |
Source code in uaef/integrations/registry.py
388 389 390 391 392 393 394 395 | |
list_connectors()
List all registered connector names in the global registry.
Returns:
| Type | Description |
|---|---|
List[str]
|
List of connector names |
Source code in uaef/integrations/registry.py
378 379 380 381 382 383 384 385 | |
register_connector(name, connector_class, override=False)
Register a connector in the global registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Library name (e.g., "ragas", "deepeval") |
required |
connector_class
|
Type[ExternalMetricConnector]
|
Connector class that implements ExternalMetricConnector interface |
required |
override
|
bool
|
If True, allow overriding existing connectors |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If connector is already registered and override is False |
TypeError
|
If connector_class does not implement required methods |
Source code in uaef/integrations/registry.py
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | |
uaef.integrations.ragas_connector
RAGAS connector for external metric integration.
RAGASConnector
Connector for RAGAS (Retrieval Augmented Generation Assessment) library.
This connector wraps RAGAS library metrics in UAEF's interface, transforming UAEF data to RAGAS format, calling RAGAS metrics, and transforming results back to UAEF MetricScore objects.
RAGAS is an external evaluation library for RAG systems that provides metrics for answer quality and tool calling accuracy.
Source code in uaef/integrations/ragas_connector.py
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 | |
calculate_answer_correctness(evaluation_input)
Calculate answer correctness using RAGAS.
Answer correctness is a comprehensive metric that combines factual accuracy and semantic similarity with the ground truth.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluation_input
|
EvaluationInput
|
UAEF evaluation input |
required |
Returns:
| Type | Description |
|---|---|
MetricScore
|
MetricScore with correctness score |
Raises:
| Type | Description |
|---|---|
ImportError
|
If the RAGAS backend ('integrations' extra) is not installed |
ValueError
|
If ground truth is not provided |
Source code in uaef/integrations/ragas_connector.py
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 | |
calculate_answer_precision(evaluation_input)
Calculate answer precision using RAGAS.
Answer precision measures how much of the generated answer is relevant and supported by the context documents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluation_input
|
EvaluationInput
|
UAEF evaluation input |
required |
Returns:
| Type | Description |
|---|---|
MetricScore
|
MetricScore with precision score |
Raises:
| Type | Description |
|---|---|
ImportError
|
If the RAGAS backend ('integrations' extra) is not installed |
ValueError
|
If required fields are missing |
Source code in uaef/integrations/ragas_connector.py
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 | |
calculate_answer_recall(evaluation_input)
Calculate answer recall using RAGAS.
Answer recall measures how much of the ground truth information is present in the generated answer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluation_input
|
EvaluationInput
|
UAEF evaluation input |
required |
Returns:
| Type | Description |
|---|---|
MetricScore
|
MetricScore with recall score |
Raises:
| Type | Description |
|---|---|
ImportError
|
If the RAGAS backend ('integrations' extra) is not installed |
ValueError
|
If ground truth is not provided |
Source code in uaef/integrations/ragas_connector.py
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 | |
calculate_context_precision(evaluation_input)
Calculate context precision using RAGAS.
Context precision measures whether the retrieved chunks ranked highest are the most relevant ones. Requires ground truth to determine which chunks are actually useful.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluation_input
|
EvaluationInput
|
UAEF evaluation input (requires context and ground truth) |
required |
Returns:
| Type | Description |
|---|---|
MetricScore
|
MetricScore with context precision score |
Source code in uaef/integrations/ragas_connector.py
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 | |
calculate_context_recall(evaluation_input)
Calculate context recall using RAGAS.
Context recall measures what percentage of the ground truth answer's claims are covered by the retrieved context. Low recall means the retriever is missing information the LLM needs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluation_input
|
EvaluationInput
|
UAEF evaluation input (requires context and ground truth) |
required |
Returns:
| Type | Description |
|---|---|
MetricScore
|
MetricScore with context recall score |
Source code in uaef/integrations/ragas_connector.py
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 | |
calculate_faithfulness(evaluation_input)
Calculate faithfulness using RAGAS.
Faithfulness measures whether every claim in the generated answer is supported by the retrieved context. A score of 1.0 means no hallucinations relative to the provided context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluation_input
|
EvaluationInput
|
UAEF evaluation input (requires context) |
required |
Returns:
| Type | Description |
|---|---|
MetricScore
|
MetricScore with faithfulness score |
Source code in uaef/integrations/ragas_connector.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 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | |
calculate_metrics(evaluation_input, metric_names)
Calculate multiple RAGAS metrics at once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluation_input
|
EvaluationInput
|
UAEF evaluation input |
required |
metric_names
|
List[str]
|
List of metric names to calculate (e.g., ["answer_precision", "answer_recall"]) |
required |
Returns:
| Type | Description |
|---|---|
List[MetricScore]
|
List of MetricScore objects |
Raises:
| Type | Description |
|---|---|
ImportError
|
If the RAGAS backend ('integrations' extra) is not installed |
ValueError
|
If an unknown metric name is provided |
Source code in uaef/integrations/ragas_connector.py
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 | |
calculate_tool_call_accuracy(evaluation_input)
Calculate tool call accuracy using RAGAS.
Tool call accuracy measures how accurately the agent selected and used tools compared to the expected tool calls.
RAGAS 0.2.x requires a MultiTurnSample for this metric, so we build a conversation with HumanMessage → AIMessage (with tool_calls) → ToolMessage sequence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluation_input
|
EvaluationInput
|
UAEF evaluation input |
required |
Returns:
| Type | Description |
|---|---|
MetricScore
|
MetricScore with tool call accuracy score |
Raises:
| Type | Description |
|---|---|
ImportError
|
If the RAGAS backend ('integrations' extra) is not installed |
ValueError
|
If ground truth tool calls are not provided |
Source code in uaef/integrations/ragas_connector.py
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 | |
is_available()
Check if RAGAS library is available.
Returns:
| Type | Description |
|---|---|
bool
|
True if RAGAS is installed and available, False otherwise |
Source code in uaef/integrations/ragas_connector.py
128 129 130 131 132 133 134 135 | |
list_available_metrics()
List all metrics supported by this connector.
Returns:
| Type | Description |
|---|---|
List[str]
|
List of metric names |
Source code in uaef/integrations/ragas_connector.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
transform_to_ragas_format(evaluation_input)
Transform UAEF EvaluationInput to RAGAS format.
RAGAS expects data in a specific format with fields like: - question: The user's question/query - answer: The agent's response - contexts: List of context documents - ground_truth: Expected correct answer - reference: Expected tool calls and arguments
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluation_input
|
EvaluationInput
|
UAEF evaluation input |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dictionary in RAGAS format |
Raises:
| Type | Description |
|---|---|
ValueError
|
If required fields are missing |
Source code in uaef/integrations/ragas_connector.py
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 | |
uaef.integrations.deepeval_connector
DeepEval connector for external metric integration.
DeepEvalConnector
Connector for DeepEval library.
This connector wraps DeepEval library metrics in UAEF's interface, transforming UAEF data to DeepEval format, calling DeepEval metrics, and transforming results back to UAEF MetricScore objects.
DeepEval is an external evaluation library that provides metrics for contextual precision/recall, hallucination detection, tool correctness, and G-Eval (custom criteria evaluation).
Source code in uaef/integrations/deepeval_connector.py
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 | |
calculate_answer_relevancy(evaluation_input)
Calculate answer relevancy using DeepEval.
Answer relevancy evaluates whether the generated answer is relevant to the user's input query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluation_input
|
EvaluationInput
|
UAEF evaluation input |
required |
Returns:
| Type | Description |
|---|---|
MetricScore
|
MetricScore with answer relevancy score |
Source code in uaef/integrations/deepeval_connector.py
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 | |
calculate_contextual_precision(evaluation_input)
Calculate contextual precision using DeepEval.
Contextual precision measures whether the retrieved context is relevant to the query and whether irrelevant context is ranked lower.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluation_input
|
EvaluationInput
|
UAEF evaluation input |
required |
Returns:
| Type | Description |
|---|---|
MetricScore
|
MetricScore with contextual precision score |
Raises:
| Type | Description |
|---|---|
ImportError
|
If the DeepEval backend ('integrations' extra) is not installed |
ValueError
|
If required fields are missing |
Source code in uaef/integrations/deepeval_connector.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 321 322 323 324 325 326 327 328 329 330 331 332 | |
calculate_contextual_recall(evaluation_input)
Calculate contextual recall using DeepEval.
Contextual recall measures whether all relevant information from the expected output can be found in the retrieved context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluation_input
|
EvaluationInput
|
UAEF evaluation input |
required |
Returns:
| Type | Description |
|---|---|
MetricScore
|
MetricScore with contextual recall score |
Raises:
| Type | Description |
|---|---|
ImportError
|
If the DeepEval backend ('integrations' extra) is not installed |
ValueError
|
If ground truth is not provided |
Source code in uaef/integrations/deepeval_connector.py
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 | |
calculate_contextual_relevancy(evaluation_input)
Calculate contextual relevancy using DeepEval.
Contextual relevancy assesses whether the retrieved context is relevant to the user's input query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluation_input
|
EvaluationInput
|
UAEF evaluation input (requires context) |
required |
Returns:
| Type | Description |
|---|---|
MetricScore
|
MetricScore with contextual relevancy score |
Source code in uaef/integrations/deepeval_connector.py
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 | |
calculate_faithfulness(evaluation_input)
Calculate faithfulness using DeepEval.
Faithfulness measures whether the generated answer is factually consistent with the provided retrieval context (i.e., no hallucinated claims).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluation_input
|
EvaluationInput
|
UAEF evaluation input (requires context) |
required |
Returns:
| Type | Description |
|---|---|
MetricScore
|
MetricScore with faithfulness score |
Source code in uaef/integrations/deepeval_connector.py
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 | |
calculate_geval(evaluation_input, criteria, evaluation_steps=None)
Calculate G-Eval score using DeepEval with custom criteria.
G-Eval is a framework for LLM-based evaluation using custom criteria. It allows defining specific evaluation criteria and steps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluation_input
|
EvaluationInput
|
UAEF evaluation input |
required |
criteria
|
str
|
Custom evaluation criteria description |
required |
evaluation_steps
|
Optional[List[str]]
|
Optional list of evaluation steps to follow |
None
|
Returns:
| Type | Description |
|---|---|
MetricScore
|
MetricScore with G-Eval score |
Raises:
| Type | Description |
|---|---|
ImportError
|
If the DeepEval backend ('integrations' extra) is not installed |
ValueError
|
If required fields are missing |
Source code in uaef/integrations/deepeval_connector.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 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 | |
calculate_hallucination(evaluation_input)
Calculate hallucination score using DeepEval.
Hallucination metric detects claims in the agent's response that are not supported by the provided context documents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluation_input
|
EvaluationInput
|
UAEF evaluation input |
required |
Returns:
| Type | Description |
|---|---|
MetricScore
|
MetricScore with hallucination score (1.0 = no hallucination, 0.0 = high hallucination) |
Raises:
| Type | Description |
|---|---|
ImportError
|
If the DeepEval backend ('integrations' extra) is not installed |
ValueError
|
If context is not provided |
Source code in uaef/integrations/deepeval_connector.py
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 | |
calculate_metrics(evaluation_input, metric_names, geval_criteria=None)
Calculate multiple DeepEval metrics at once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluation_input
|
EvaluationInput
|
UAEF evaluation input |
required |
metric_names
|
List[str]
|
List of metric names to calculate (e.g., ["contextual_precision", "hallucination"]) |
required |
geval_criteria
|
Optional[str]
|
Optional criteria for G-Eval metric |
None
|
Returns:
| Type | Description |
|---|---|
List[MetricScore]
|
List of MetricScore objects |
Raises:
| Type | Description |
|---|---|
ImportError
|
If the DeepEval backend ('integrations' extra) is not installed |
ValueError
|
If an unknown metric name is provided |
Source code in uaef/integrations/deepeval_connector.py
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 | |
calculate_role_adherence(evaluation_input)
Calculate role adherence using DeepEval's RoleAdherenceMetric.
Reads the chatbot persona strictly from
ground_truth.expected_arguments["chatbot_role"]. Builds a
ConversationalTestCase from trace.messages, delegates to
DeepEval, and surfaces the score along with per-turn out-of-character
verdicts in metadata.
Returns a not_applicable MetricScore if chatbot_role is missing
or the filtered turn list is empty. Errors raised by DeepEval's
measure() propagate to the caller (matches sibling methods).
Source code in uaef/integrations/deepeval_connector.py
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 | |
calculate_tool_correctness(evaluation_input)
Calculate tool correctness using DeepEval.
Tool correctness measures how accurately the agent selected and used tools compared to the expected tool calls.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluation_input
|
EvaluationInput
|
UAEF evaluation input |
required |
Returns:
| Type | Description |
|---|---|
MetricScore
|
MetricScore with tool correctness score |
Raises:
| Type | Description |
|---|---|
ImportError
|
If the DeepEval backend ('integrations' extra) is not installed |
ValueError
|
If ground truth tool calls are not provided |
Source code in uaef/integrations/deepeval_connector.py
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 | |
is_available()
Check if DeepEval library is available.
Returns:
| Type | Description |
|---|---|
bool
|
True if DeepEval is installed and available, False otherwise |
Source code in uaef/integrations/deepeval_connector.py
152 153 154 155 156 157 158 159 | |
list_available_metrics()
List all metrics supported by this connector.
Returns:
| Type | Description |
|---|---|
List[str]
|
List of metric names |
Source code in uaef/integrations/deepeval_connector.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
transform_to_deepeval_format(evaluation_input)
Transform UAEF EvaluationInput to DeepEval format.
DeepEval expects data in a specific format with fields like: - input: The user's question/query - actual_output: The agent's response - retrieval_context: List of context documents - expected_output: Expected correct answer - context: List of context strings for hallucination detection - tools_called: List of tool calls made by the agent - expected_tools: List of expected tool calls
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluation_input
|
EvaluationInput
|
UAEF evaluation input |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dictionary in DeepEval format |
Raises:
| Type | Description |
|---|---|
ValueError
|
If required fields are missing |
Source code in uaef/integrations/deepeval_connector.py
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 | |