kunishou commited on
Commit
b4e13a0
1 Parent(s): 6085d2e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -13
app.py CHANGED
@@ -29,20 +29,25 @@ def evaluate(
29
 
30
  df_result = pd.DataFrame([[instruction, input, None, None],],columns=["instruction" ,"input", "output", "total_tokens"])
31
 
32
- response = openai.ChatCompletion.create(
33
- model="gpt-3.5-turbo",
34
- # model="gpt-4",
35
- messages=[
36
- {"role": "system", "content": "You are a useful assistant."},
37
- {"role": "user", "content": message },
38
- ],
39
- n=1,
40
- presence_penalty=-2.0,
41
- max_tokens=512
42
- )
 
 
 
 
43
 
44
- df_result.iloc[0, 2] = response["choices"][0]["message"]["content"]
45
- df_result.iloc[0, 3] = response["usage"]["total_tokens"]
 
46
 
47
  now = datetime.datetime.now()
48
  file_name = f'chatgpt3/test_{now.strftime("%Y%m%d_%H%M%S")}.csv'
 
29
 
30
  df_result = pd.DataFrame([[instruction, input, None, None],],columns=["instruction" ,"input", "output", "total_tokens"])
31
 
32
+ if os.environ["PROMPT2"] in message:
33
+ response = openai.ChatCompletion.create(
34
+ model="gpt-3.5-turbo",
35
+ # model="gpt-4",
36
+ messages=[
37
+ {"role": "system", "content": "You are a useful assistant."},
38
+ {"role": "user", "content": message },
39
+ ],
40
+ n=1,
41
+ presence_penalty=-2.0,
42
+ max_tokens=512
43
+ )
44
+
45
+ df_result.iloc[0, 2] = response["choices"][0]["message"]["content"]
46
+ df_result.iloc[0, 3] = response["usage"]["total_tokens"]
47
 
48
+ else:
49
+ df_result.iloc[0, 2] = ""
50
+ df_result.iloc[0, 3] = 0
51
 
52
  now = datetime.datetime.now()
53
  file_name = f'chatgpt3/test_{now.strftime("%Y%m%d_%H%M%S")}.csv'