| 1 | |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | import argparse |
| 6 | from typing import Any |
| 7 | |
| 8 | from .catalog import validate_catalog |
| 9 | |
| 10 | |
| 11 | def print_validation_result(result: dict[str, Any]) -> None: |
| 12 | |
| 13 | |
| 14 | print("Katalog doğrulandı.") |
| 15 | print(f"Intent: {result['intent_count']}") |
| 16 | print(f"Cevap: {result['response_count']}") |
| 17 | print(f"Kategori: {result['category_count']}") |
| 18 | print(f"Örnek soru: {result['example_question_count']}") |
| 19 | |
| 20 | |
| 21 | def build_parser() -> argparse.ArgumentParser: |
| 22 | parser = argparse.ArgumentParser(description="Hezarfen kullanım asistanı chatbot'u") |
| 23 | parser.add_argument( |
| 24 | "--validate", |
| 25 | action="store_true", |
| 26 | help="Intent kataloğunu doğrular ve çıkar.", |
| 27 | ) |
| 28 | parser.add_argument( |
| 29 | "--evaluate", |
| 30 | action="store_true", |
| 31 | help="Benchmark üzerinde tam değerlendirme raporu üretir.", |
| 32 | ) |
| 33 | parser.add_argument( |
| 34 | "--selective", |
| 35 | action="store_true", |
| 36 | help="Seçici sınıflandırma raporu (risk-coverage, AURC, OOS false-accept).", |
| 37 | ) |
| 38 | parser.add_argument( |
| 39 | "--mutation", |
| 40 | action="store_true", |
| 41 | help="Mutasyon testi: kritik invariant'ların yakalanma gücü (mutation score).", |
| 42 | ) |
| 43 | parser.add_argument( |
| 44 | "--chat", |
| 45 | action="store_true", |
| 46 | help="Etkileşimli terminal sohbetini başlatır.", |
| 47 | ) |
| 48 | return parser |
| 49 | |
| 50 | |
| 51 | def main() -> int: |
| 52 | args = build_parser().parse_args() |
| 53 | if args.chat: |
| 54 | from .cli import main as chat_main |
| 55 | |
| 56 | return chat_main() |
| 57 | |
| 58 | if args.evaluate: |
| 59 | from .evaluation import format_report, run_evaluation |
| 60 | |
| 61 | print(format_report(run_evaluation())) |
| 62 | return 0 |
| 63 | |
| 64 | if args.selective: |
| 65 | from .evaluation.selective import compute, format_report as fmt_sel |
| 66 | |
| 67 | print(fmt_sel(compute())) |
| 68 | return 0 |
| 69 | |
| 70 | if args.mutation: |
| 71 | from .evaluation.mutation import compute, format_report as fmt_mut |
| 72 | |
| 73 | print(fmt_mut(compute())) |
| 74 | return 0 |
| 75 | |
| 76 | if args.validate: |
| 77 | print_validation_result(validate_catalog()) |
| 78 | return 0 |
| 79 | |
| 80 | |
| 81 | print_validation_result(validate_catalog()) |
| 82 | print("Chatbot motoru henüz eklenmedi.") |
| 83 | return 0 |
| 84 | |
| 85 | |
| 86 | if __name__ == "__main__": |
| 87 | raise SystemExit(main()) |