Update app.py
Browse files
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 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
43 |
|
44 |
-
|
45 |
-
|
|
|
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'
|