-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
86 lines (57 loc) · 2.22 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import logging
import os # if you have not already done this
import readline
import signal
import sys
import torch
import acog.prompt as prompt
#import acog.memory as memory
import acog.text as text
from acog.util import log as acog_log
#from transformers import AutoTokenizer, AutoModelForCausalLM
#fd = os.open('/dev/null',os.O_WRONLY)
#os.dup2(fd,2)
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
def sigint_handler(signal, frame):
print("\nBye now!")
sys.exit(0)
signal.signal(signal.SIGINT, sigint_handler)
CHARACTER_NAME = "Amura"
CHARACTER_PERSONA = "Heyo gang. My name is Hasano Amura and I'm a university student majoring in compsci. I'm currently working with a gamedev team on a Unity game... It's well, uhh, it's a gacha game with poorly drawn card art... But I have to make money to pay the rent you know? Don't judge..."
def process_prompt(p):
return text.generate(p)
def cli_get_input():
return input("You: ")
def main():
#memory.initialize()
text.initialize()
history = prompt.create_history([
{
"you": "So, why did you get into gamedev?",
"bot": "I had this idea, and a passion. I did a couple indie things before getting this job, but my solo efforts didn't really pan out."
},
{
"you": "Are you not much of a marketing/sales person?",
"bot": "Oh my god! Not at all, it's kinda why I gave up on indie as a whole..."
}
])
while(True):
acog_log("history", history)
# Get User Input
input = cli_get_input()
# acog_log("input", input)
# Convert input into embeddings and store it
#memory.store(input)
# Generate a prompt
p = prompt.create(CHARACTER_NAME, CHARACTER_PERSONA, history, input)
acog_log("prompt", p)
# Turn prompt into an output message
output = process_prompt(p)
print(f"Amura: {output}")
prompt.update_history(history, {"you": input, "bot": output})
# Dump memory to see what we have (pure debugging)
#payloads = memory.search(input)
#for idx, payload in enumerate(payloads):
# print(f"{idx}: {payload}")
if __name__ == "__main__":
main()