Spaces:
Running
Running
| import pprint | |
| from argdown_feedback.tasks.base import Evaluation | |
| from argdown_feedback.verifiers.base import CompositeHandler | |
| from argdown_feedback.verifiers.core.infreco_handler import InfRecoCompositeHandler, NoPropInlineDataHandler, HasGistHandler | |
| from argdown_feedback.verifiers.core.logreco_handler import LogRecoCompositeHandler | |
| from argdown_feedback.verifiers.core.content_check_handler import HasArgdownHandler | |
| from argdown_feedback.verifiers.processing_handler import DefaultProcessingHandler | |
| from argdown_feedback.verifiers.verification_request import VerificationRequest | |
| def run_verification_pipeline(inputs, verifier_id): | |
| if verifier_id == "log_reco": | |
| return run_log_reco(inputs) | |
| return "Not implemented" | |
| def run_log_reco(inputs): | |
| if not inputs: | |
| return "No input provided" | |
| infreco_handler = InfRecoCompositeHandler() | |
| infreco_handler.handlers = [ | |
| h for h in infreco_handler.handlers | |
| if not isinstance(h, NoPropInlineDataHandler) and not isinstance(h, HasGistHandler) | |
| ] | |
| handler = CompositeHandler( | |
| handlers=[ | |
| DefaultProcessingHandler(), | |
| HasArgdownHandler(), | |
| infreco_handler, | |
| LogRecoCompositeHandler(), | |
| ] | |
| ) | |
| request = VerificationRequest(inputs=inputs) | |
| result = handler.process(request) | |
| evaluation = Evaluation.from_verification_request(result) | |
| report_lines = [] | |
| report_lines.append("## Verification Results\n") | |
| if evaluation.is_valid: | |
| report_lines.append("✅ All clear. No issues detected in the input.") | |
| else: | |
| report_lines.append("❌ The input is flawed.") | |
| report_lines.append("\n### Issues\n") | |
| for k,v in evaluation.metrics.items(): | |
| if v is not None: | |
| report_lines.append(f"‼️ {v}\n") | |
| return "\n".join(report_lines) | |