Skip to content

Instantly share code, notes, and snippets.

@rfeers
Created December 19, 2023 16:18
Show Gist options
  • Save rfeers/706ab391f5b5540ce35f07e5de940b02 to your computer and use it in GitHub Desktop.
Save rfeers/706ab391f5b5540ce35f07e5de940b02 to your computer and use it in GitHub Desktop.
def theme_analyzer(review):
response = openai.completions.create(
model="text-davinci-003", # You can choose the model version
prompt=f"""Analyze the following review: \"{review}\".
Is it a complain, a experience-based review or a question.
Answer with a single word:
- Complain
- Experience
- Question""",
max_tokens=60
)
df_short["Theme"] = df_short.apply(lambda x:theme_analyzer(x["Text"]), axis=1)
df_short
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment