Created
December 19, 2023 16:14
-
-
Save rfeers/76b473f339c9d552d6ab7fc687ed656c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Summary funnction | |
def summary_maker(review): | |
response = openai.completions.create( | |
model="text-davinci-003", # You can choose the model version | |
prompt=f"Summarize the following review: \"{review}\" with a 3 words sentence.", | |
max_tokens=60 | |
) | |
sentiment = response.choices[0].text.strip() | |
return sentiment | |
df_short["Summary_new"] = df_short.apply(lambda x:summary_maker(x["Text"]), axis=1) | |
df_short |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment