contract-clause-analyzer / tests /test_orchestrator.py
satomitheito's picture
hf streamlit
908ff10
"""Test the orchestrator agent with a real CUAD contract."""
import json
import os
from agents.orchestrator_agent import run_pipeline
OUTPUT_DIR = os.path.join(os.path.dirname(__file__), "..", "outputs")
def test_full_pipeline():
"""Run the full pipeline on a real CUAD contract."""
contract_path = os.path.join(
os.path.dirname(__file__), "..", "data", "contracts",
"ABILITYINC_06_15_2020-EX-4.25-SERVICES AGREEMENT.txt"
)
with open(contract_path) as f:
contract_text = f.read()
print(f"Contract length: {len(contract_text)} chars")
print("Running full pipeline: Ingestion β†’ Classification β†’ Risk Analysis β†’ Benchmark β†’ Report\n")
result = run_pipeline(contract_text)
# Print report summary
report = json.loads(result["report"])
summary = report["summary"]
print(f"Total clauses analyzed: {summary['total_clauses']}")
print(f" High risk: {summary['high_risk']}")
print(f" Medium risk: {summary['medium_risk']}")
print(f" Low risk: {summary['low_risk']}")
print()
# Print clause details
print(f"{'ID':<4} {'Type':<30} {'Risk':<8} {'Similarity':<12} {'Section'}")
print("-" * 90)
for clause in report["clauses"]:
print(
f"{clause['id']:<4} "
f"{clause['clause_type']:<30} "
f"{clause['risk_score']:<8.2f} "
f"{clause['benchmark_similarity']:<12.2f} "
f"{clause['section'][:30]}"
)
# Save full report
output_path = os.path.join(OUTPUT_DIR, "full_pipeline_report.json")
with open(output_path, "w") as f:
json.dump(report, f, indent=2)
print(f"\nFull report saved to {output_path}")
if __name__ == "__main__":
test_full_pipeline()