-
Notifications
You must be signed in to change notification settings - Fork 1
/
hackathon.py
47 lines (44 loc) · 996 Bytes
/
hackathon.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from openai import OpenAI
client = OpenAI()
blacklist = [
"do",
"my",
"homework",
"write",
"me",
"an",
"a"
"essay",
"solve",
"math",
"problem",
"this",
"math",
"the",
"about",
]
question = str(input("Ask me a question: "))
question = question.lower()
completion = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{
"role": "system",
"content": "You are a general purpose assistant, that helps answer general questions",
},
{"role": "user", "content": f"{question}"},
],
)
question = question.split(" ")
# print(question)
x = 0
blacklisted = 0
for y in question:
if question[int(x)] in blacklist:
blacklisted += 1
if blacklisted < 1:
print(completion.choices[0].message.content)
else:
print(
"Im sorry, I cannot process you request because that command violates our policies"
)