-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
63 lines (46 loc) · 1.33 KB
/
main.py
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
59
60
61
62
63
import os
from domain.home import room
from dotenv import load_dotenv
load_dotenv()
import domain.primitives.file as file
import domain.primitives.time as time
import domain.primitives.control as control
import domain.core.memory as memory
from llm.session import (
Session,
Param,
SessionEndError,
GPT3_5_FUNCTION,
GPT4O_FUNCTION,
GPT4O_MINI,
SessionResponseContext,
GPT3_5_FUNCTION_16K,
SessionGroup,
)
from colorama import Fore, Style
def print_response(message: SessionResponseContext) -> None:
print(
f"{Fore.BLUE}Aeris {Style.RESET_ALL}{Style.DIM}({message.model}) {Style.NORMAL}{Fore.BLUE} >> {Style.RESET_ALL} {message.content}"
)
if not (token := os.getenv("OPENAI_API_KEY")):
raise Exception("'OPENAI_API_KEY not found")
session = Session(
token=token, default_model=GPT4O_MINI, response_callback=print_response
)
session.add_group(time.group)
session.add_group(file.group)
session.add_group(control.group)
session.add_group(memory.group)
session.add_group(room.group)
def main() -> None:
try:
while True:
text = input(f"{Fore.GREEN}User >> {Style.RESET_ALL}")
session.make_request(text)
except SessionEndError:
pass
except KeyboardInterrupt:
pass
print("\n-- Done --")
if __name__ == "__main__":
main()