Upload chat-aurora.py
Browse files- chat-aurora.py +43 -0
chat-aurora.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
import sys
|
3 |
+
chat_history = []
|
4 |
+
|
5 |
+
max_chat_history = 8
|
6 |
+
|
7 |
+
url = sys.argv[1]
|
8 |
+
system_prompt = sys.argv[2]
|
9 |
+
|
10 |
+
def respond(prompt):
|
11 |
+
prompt = prompt.strip()
|
12 |
+
global chat_history
|
13 |
+
chat_history=chat_history[-max_chat_history:]
|
14 |
+
if prompt=="clear conversation":
|
15 |
+
chat_history = []
|
16 |
+
return "Cleared Conversation."
|
17 |
+
else:
|
18 |
+
chat_history.append(prompt if len(chat_history) < 2 else "# User Instruction: " + prompt)
|
19 |
+
response = requests.post(url, json={
|
20 |
+
"data": [
|
21 |
+
system_prompt,
|
22 |
+
"\n".join(chat_history),
|
23 |
+
"",
|
24 |
+
"",
|
25 |
+
0.77,
|
26 |
+
0.9,
|
27 |
+
22,
|
28 |
+
192,
|
29 |
+
True,
|
30 |
+
0.0,
|
31 |
+
1.11,
|
32 |
+
"\n\n",
|
33 |
+
]
|
34 |
+
}).json()
|
35 |
+
data = response["data"][0]
|
36 |
+
chat_history.append("# You gave this response: " + data)
|
37 |
+
print()
|
38 |
+
return "(Aurora): " + data
|
39 |
+
|
40 |
+
username = input("Username: ")
|
41 |
+
while True:
|
42 |
+
print()
|
43 |
+
print(respond(input(f'({username}): ')))
|