File size: 1,872 Bytes
129298c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
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
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)