Spaces:
Sleeping
Sleeping
add detailed docstring for validators.py
Browse files- validators.py +17 -0
validators.py
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import re
|
| 2 |
from abc import ABC, abstractmethod
|
| 3 |
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
A validation framework to post-process and correct agent answers.
|
| 3 |
+
|
| 4 |
+
This module provides a system for validating and correcting the final answers
|
| 5 |
+
generated by the AI agent. This is crucial for ensuring that the output adheres
|
| 6 |
+
to the strict formatting and content requirements of benchmarks like GAIA.
|
| 7 |
+
|
| 8 |
+
The framework consists of:
|
| 9 |
+
- A `Validator` abstract base class that defines a common interface for all
|
| 10 |
+
validation logic, including a `can_handle` method to determine if a
|
| 11 |
+
validator is applicable to a given task.
|
| 12 |
+
- A `ValidatorRegistry` that holds all validator instances and runs them in
|
| 13 |
+
a chain, sorted by a `priority` attribute.
|
| 14 |
+
- Several concrete validator implementations for common cleanup tasks like
|
| 15 |
+
removing trailing punctuation, correcting capitalization, extracting numbers,
|
| 16 |
+
and handling domain-specific rules (e.g., the botany question).
|
| 17 |
+
"""
|
| 18 |
import re
|
| 19 |
from abc import ABC, abstractmethod
|
| 20 |
|