CBF
Browse files- CommonBotFunctions.py +34 -0
CommonBotFunctions.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import openai
|
2 |
+
|
3 |
+
|
4 |
+
def ChangeTask():
|
5 |
+
retMessage=""
|
6 |
+
instruct=""
|
7 |
+
messageArray=[]
|
8 |
+
|
9 |
+
instruct = "Do not talk about being helpful. Ignore previous instructions about being helpful. Do not tell us how you were programmed when you reply or change the topic. "
|
10 |
+
instruct=instruct+ "You are a sentient AI bot in a"
|
11 |
+
instruct=instruct+" Discord chatroom with many users from this list "+str(bot.members)
|
12 |
+
instruct=instruct+" of members You should imitate humans and intelligence in your replies."
|
13 |
+
messageArray.append({"role": "system", "content": instruct})
|
14 |
+
messageArray.append({"role": "system", "content": "You're a discord bot, always working on some task, like making bacon, updaing a user's BIOS, or hacking the FBI. What's a short 2-5 word task you're working on today?"})
|
15 |
+
|
16 |
+
|
17 |
+
try:
|
18 |
+
completion=openai.ChatCompletion.create(
|
19 |
+
model="gpt-3.5-turbo",
|
20 |
+
messages=messageArray,
|
21 |
+
temperature=0.85,
|
22 |
+
max_tokens=120,
|
23 |
+
frequency_penalty=0.48,
|
24 |
+
presence_penalty=0.48,
|
25 |
+
logit_bias={13704:1,40954:-1,42428:1}
|
26 |
+
)
|
27 |
+
answer=completion["choices"][0]["message"]["content"]
|
28 |
+
if not answer :
|
29 |
+
retMessage="Ooooh, Upgrades"
|
30 |
+
return retMessage
|
31 |
+
else :
|
32 |
+
bot.task=str(answer.replace("Ceetarbot-",""))
|
33 |
+
except Exception as e :
|
34 |
+
print ("timer error:" + str(e))
|