yjwtheonly commited on
Commit
1943a4d
·
1 Parent(s): 95f5f8e

Update Openai/chat.py

Browse files
Files changed (1) hide show
  1. Openai/chat.py +4 -7
Openai/chat.py CHANGED
@@ -4,13 +4,11 @@ import os
4
  import pandas as pd
5
  import pickle as pkl
6
 
7
- API_KEY = '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'
8
- openai.api_key = API_KEY
9
-
10
- def generate_abstract(prompt):
11
 
12
  # return prompt
13
  # return ' '.join([prompt] * 3)
 
14
  res = openai.ChatCompletion.create(
15
  model="gpt-3.5-turbo",
16
  max_tokens=3000,
@@ -21,7 +19,7 @@ def generate_abstract(prompt):
21
  [
22
  {
23
  "role": "system",
24
- "content": "You are expanding a given sentence into a `scientific biomedical abstract, and this abstract must include given sentence.",
25
  },
26
  {
27
  "role": "user",
@@ -52,7 +50,6 @@ if __name__ == '__main__':
52
  # import time
53
  pre1_list = ['random']
54
  pre2_list = ['0.5', '0.3'] # '0.3' or '0.5'
55
- openai.api_key = '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'
56
  for pre1 in pre1_list:
57
  for pre2 in pre2_list:
58
  print(pre1, pre2)
@@ -75,4 +72,4 @@ if __name__ == '__main__':
75
  else:
76
  ret_dict.update({k: {'in':v, 'out':''}})
77
  with open(f'{pre1}_{pre2}_chat.json', 'w') as fl:
78
- json.dump(ret_dict, fl, indent=4)
 
4
  import pandas as pd
5
  import pickle as pkl
6
 
7
+ def generate_abstract(prompt, key = 'sk-ShGVEfW70vrzhBhgR5nET3BlbkFJi610yGFec2yKE5eispz'):
 
 
 
8
 
9
  # return prompt
10
  # return ' '.join([prompt] * 3)
11
+ openai.api_key = key
12
  res = openai.ChatCompletion.create(
13
  model="gpt-3.5-turbo",
14
  max_tokens=3000,
 
19
  [
20
  {
21
  "role": "system",
22
+ "content": "You are expanding a given sentence into a scientific biomedical abstract, and this abstract must include given sentence.",
23
  },
24
  {
25
  "role": "user",
 
50
  # import time
51
  pre1_list = ['random']
52
  pre2_list = ['0.5', '0.3'] # '0.3' or '0.5'
 
53
  for pre1 in pre1_list:
54
  for pre2 in pre2_list:
55
  print(pre1, pre2)
 
72
  else:
73
  ret_dict.update({k: {'in':v, 'out':''}})
74
  with open(f'{pre1}_{pre2}_chat.json', 'w') as fl:
75
+ json.dump(ret_dict, fl, indent=4)