转载

ChatGPT插件例子 高级推文分类器

这是检测情绪的高级提示。它允许您为其提供状态更新列表,然后为每个更新提供情绪。

提问

将这些推文中的情绪分类:
1.“我受不了家庭作业”
2.“这糟透了。我很无聊😠”
3.“我等不及万圣节了!!!” 
4.“我的猫很可爱❤️❤️”
5.“我讨厌巧克力”
推文情绪评分:

回答

1. 负面 

2. 负面 

3. 正面 

4. 正面 

5. 负面

API请求

<font size="3">import os
import openai

openai.api_key = os.getenv("OPENAI_API_KEY")

response = openai.Completion.create(
  model="text-davinci-003",
  prompt="Classify the sentiment in these tweets:\n\n1. \"I can't stand homework\"\n2. \"This sucks. I'm bored 😠\"\n3. \"I can't wait for Halloween!!!\"\n4. \"My cat is adorable ❤️❤️\"\n5. \"I hate chocolate\"\n\nTweet sentiment ratings:",
  temperature=0,
  max_tokens=60,
  top_p=1.0,
  frequency_penalty=0.0,
  presence_penalty=0.0
)</font>