Ceetar commited on
Commit
7ae7af3
·
1 Parent(s): 7773f34
Files changed (1) hide show
  1. CommonBotFunctions.py +36 -21
CommonBotFunctions.py CHANGED
@@ -1,34 +1,49 @@
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))
 
1
  import openai
2
+ from nltk.tokenize import word_tokenize
3
+ import nltk
4
+ nltk.download('punkt')
5
 
6
+ def isQuestion(q):
7
+ print(q)
8
+ question_words = ["what", "why", "when", "where",
9
+ "name", "is", "how", "do", "does",
10
+ "which", "are", "could", "would",
11
+ "should", "has", "have", "whom", "whose", "don't"]
12
 
13
+ question = q
14
+ question = question.lower()
15
+ question = word_tokenize(question)
16
+
17
+ if any(x in question[0] for x in question_words):
18
+ print(q)
19
+ return True
20
+ else:
21
+ return False
22
+
23
+ def ChangeTask(botMember):
24
  retMessage=""
25
  instruct=""
26
  messageArray=[]
27
 
28
  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. "
29
  instruct=instruct+ "You are a sentient AI bot in a"
30
+ instruct=instruct+" Discord chatroom with many users from this list "+str(botMember)
31
  instruct=instruct+" of members You should imitate humans and intelligence in your replies."
32
  messageArray.append({"role": "system", "content": instruct})
33
  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?"})
34
 
35
+ completion=openai.ChatCompletion.create(
36
+ model="gpt-3.5-turbo",
37
+ messages=messageArray,
38
+ temperature=0.85,
39
+ max_tokens=120,
40
+ frequency_penalty=0.48,
41
+ presence_penalty=0.48,
42
+ logit_bias={13704:1,40954:-1,42428:1}
43
+ )
44
+ answer=completion["choices"][0]["message"]["content"]
45
+ if not answer :
46
+ retMessage="Ooooh, Upgrades"
47
+ return retMessage
48
+ else :
49
+ return str(answer.replace("Ceetarbot-",""))