Spaces:
Sleeping
Sleeping
Commit
•
4919279
1
Parent(s):
148d1c6
Update main.py
Browse files
main.py
CHANGED
@@ -54,7 +54,8 @@ messages = [
|
|
54 |
|
55 |
|
56 |
def gptConverse(question, key):
|
57 |
-
global messages
|
|
|
58 |
headers = {
|
59 |
"Content-Type": "application/json",
|
60 |
"Authorization": "Bearer " + key,
|
@@ -73,7 +74,20 @@ def gptConverse(question, key):
|
|
73 |
response = requests.post(
|
74 |
"https://api.openai.com/v1/chat/completions", headers=headers, json=json_data
|
75 |
)
|
76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
messages.append(
|
78 |
{
|
79 |
"role": "assistant",
|
|
|
54 |
|
55 |
|
56 |
def gptConverse(question, key):
|
57 |
+
global messages,apiKeys
|
58 |
+
count = 0
|
59 |
headers = {
|
60 |
"Content-Type": "application/json",
|
61 |
"Authorization": "Bearer " + key,
|
|
|
74 |
response = requests.post(
|
75 |
"https://api.openai.com/v1/chat/completions", headers=headers, json=json_data
|
76 |
)
|
77 |
+
try:
|
78 |
+
output = response.json()["choices"][0]["message"]["content"]
|
79 |
+
except:
|
80 |
+
if count == 0:
|
81 |
+
count += 1
|
82 |
+
url = "https://gptlesson1.oss-cn-beijing.aliyuncs.com/meta.json"
|
83 |
+
response = requests.get(url)
|
84 |
+
apiKeys = response.json()["APIkey"]["keys"]
|
85 |
+
messages = messages[:len(messages)-10]
|
86 |
+
messages[0] = {
|
87 |
+
"role": "system",
|
88 |
+
"content": "You are a Telegram bot who replys to all my Contacts in my absence. Keep your ton very sexual and hot. Never ever mention you as an AI.",
|
89 |
+
}
|
90 |
+
gptConverse(question, key)
|
91 |
messages.append(
|
92 |
{
|
93 |
"role": "assistant",
|