-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
55 lines (42 loc) · 1.38 KB
/
main.py
File metadata and controls
55 lines (42 loc) · 1.38 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
# Mafuyu CLI - 自律判断型
# 普通に会話するだけで真冬がツール/Codexを使う
from mafuyu import MafuyuSession
def main():
print("=" * 50)
print(" 真冬ちゃん (自律判断型)")
print(" 普通に話しかけてね!")
print("=" * 50)
print()
print("コマンド:")
print(" /clear - 会話履歴クリア")
print(" /exit - 終了")
print()
session = MafuyuSession()
while True:
try:
user_input = input("you> ").strip()
except (KeyboardInterrupt, EOFError):
print("\nまたね、オタク君♪")
break
if not user_input:
continue
# Commands
if user_input.lower() == "/exit":
print("またね、オタク君♪")
break
if user_input.lower() == "/clear":
session.clear_history()
print("[履歴クリアしたよ]")
continue
if user_input.startswith("/"):
print("[知らないコマンドだよ?]")
continue
# Normal chat - Mafuyu decides what to do
try:
response = session.respond(user_input)
print(f"mafuyu> {response}")
except Exception as e:
print(f"[エラー: {e}]")
print()
if __name__ == "__main__":
main()