From f6165671558f8045f3a6fd5dd47999d062fd6e68 Mon Sep 17 00:00:00 2001 From: Ashik K Date: Thu, 6 Apr 2023 17:31:20 +0200 Subject: [PATCH] Fix for using turbo model and other minor cleanups --- titlegen.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/titlegen.py b/titlegen.py index c0585f8..ca67cd2 100644 --- a/titlegen.py +++ b/titlegen.py @@ -19,20 +19,19 @@ with open(sys.argv[1], "r") as file: # in one sentence:" and the text in the 5th column prompt = "Summarize this in one English sentence of not more than 4 words:" + row[4] - response = openai.Completion.create( - model="gpt-3.5-turbo", - prompt=prompt, - temperature=0.7, - max_tokens=64, - top_p=1.0, - frequency_penalty=0.0, - presence_penalty=0.0 + completion = openai.ChatCompletion.create( # 1. Change the function Completion to ChatCompletion + model = 'gpt-3.5-turbo', + messages = [ + {'role': 'user', 'content': prompt} + ], + temperature = 0 ) + # write the response as the last column in each row of the same csv file - row.append(response) + row.append(completion['choices'][0]['message']['content']) print(row) # write the row to the csv file writer.writerow(row) - outfile.close() - file.close() + outfile.close() + file.close()