-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAIQuestionBox.py
More file actions
35 lines (35 loc) · 972 Bytes
/
AIQuestionBox.py
File metadata and controls
35 lines (35 loc) · 972 Bytes
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
import os
import openai
def getFileContents(filename, output):
with open(filename, 'r') as f:
output = f.read()
return output
log = open("Config Files/Output.txt", "r")
lines = ""
liney = ""
my_secret = getFileContents("Config Files/key.txt", liney)
openai.api_key = (my_secret)
response_output = ("")
response = openai.Completion.create(
model="text-davinci-002",
prompt=input("Please Enter Your Chemistry Question: "),
temperature=1,
max_tokens=4000,
top_p=1,
frequency_penalty=0.43,
presence_penalty=0.66
)
(response_output) = str(response)
text = response['choices'][0]['text']
with open("Config Files/Output.txt", "r") as file1:
line = file1.readlines()
file1.close
with open("Config Files/Output.txt", 'w') as file:
file.write(str(text))
for number, line in enumerate(lines):
if number not in [4, 7]:
file.write(line)
file.close()
with open('Config Files/Output.txt', 'r') as f:
print(f.read())
f.close()