forked from patham9/NarsGPT
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Demo1_LearnAboutUser.py
29 lines (25 loc) · 1010 Bytes
/
Demo1_LearnAboutUser.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
import NarsGPT as NAR
LearnMoreAbout = "me" #"the router"
UseLastQuestionInContext = True
lastquestion = ""
def AddInput(inp):
if not inp.endswith("?") and not inp.startswith("*") and UseLastQuestionInContext:
inp = lastquestion + " " + inp
ret = NAR.AddInput(inp, PrintAnswer=False, Print=False, PrintInputSentenceOverride=True, PrintInputSentenceOverrideValue=False)
if inp.endswith("?"):
print(ret["GPT_Answer"])
def RaiseQuestion():
global lastquestion
ret = NAR.AddInput(f"Raise a question about {LearnMoreAbout}, not addressed by any existing memory item?", PrintAnswer=False, Print=False, PrintInputSentenceOverride=True, PrintInputSentenceOverrideValue=False)
ret["GPT_Answer"] = ret["GPT_Answer"].split("?")[0] + "?"
print(ret["GPT_Answer"])
NAR.I_You_Exchange(ret)
lastquestion = ret["GPT_Answer"]
RaiseQuestion()
while True:
try:
inp = input().rstrip("\n").strip()
except:
exit(0)
AddInput(inp)
RaiseQuestion()