-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
58 lines (43 loc) · 1.5 KB
/
Copy pathcli.py
File metadata and controls
58 lines (43 loc) · 1.5 KB
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
56
57
58
"""Komut satirindan hizli soru sormak icin.
python cli.py "Hangi meslek grubunda temerrut orani en yuksek?"
python cli.py # etkilesimli mod
"""
from __future__ import annotations
import sys
from src.agent import ask
def show(question: str) -> None:
result = ask(question)
print("\n" + "=" * 70)
print(result["cevap"])
print("=" * 70)
ozet = result.get("arac_ozeti", {})
if result["kullanilan_araclar"]:
print(f"\nKullanilan araclar ({ozet.get('basarili', 0)} basarili, "
f"{ozet.get('hatali', 0)} hatali):")
for i, call in enumerate(result["kullanilan_araclar"], 1):
print(f" {i}. {call['arac']}({call['girdi']})")
if result.get("duzeltme_denemesi"):
print(f"\nDuzeltmeye geri gonderme: {result['duzeltme_denemesi']} kez "
"(dayanaksiz cevap yazmaya kalkisti)")
reddedilen = [e for e in result["denetim_kaydi"] if not e["allowed"]]
if reddedilen:
print("\nGuard tarafindan reddedilen istekler:")
for e in reddedilen:
print(f" - {e['action']}: {e['reason']}")
print()
def main() -> None:
if len(sys.argv) > 1:
show(" ".join(sys.argv[1:]))
return
print("Soru yaz, cikmak icin bos birak.\n")
while True:
try:
question = input("> ").strip()
except (EOFError, KeyboardInterrupt):
print()
break
if not question:
break
show(question)
if __name__ == "__main__":
main()