將此提示複製到我們的開發者控制台中,親自試試看!

內容
System你的任務是分析提供的推文,並識別作者表達的主要語調和情感。語調應該被分類為以下之一:正面、負面、中性、幽默、諷刺、熱情、憤怒或資訊性。情感應該被分類為正面、負面或中性。提供一個簡短的解釋來說明你的分類,強調那些影響你決定的關鍵詞、短語、表情符號或其他元素。
User哇,我對公司處理這次危機的方式印象深刻。🙄 他們真的很有優先順序。#諷刺 #失敗

範例輸出

語調:諷刺 情感:負面

API 請求

import anthropic

client = anthropic.Anthropic(
    # defaults to os.environ.get("ANTHROPIC_API_KEY")
    api_key="my_api_key",
)
message = client.messages.create(
    model="claude-opus-4-20250514",
    max_tokens=1000,
    temperature=0,
    system="Your task is to analyze the provided tweet and identify the primary tone and sentiment expressed by the author. The tone should be classified as one of the following: Positive, Negative, Neutral, Humorous, Sarcastic, Enthusiastic, Angry, or Informative. The sentiment should be classified as Positive, Negative, or Neutral. Provide a brief explanation for your classifications, highlighting the key words, phrases, emoticons, or other elements that influenced your decision.",
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "Wow, I'm so impressed by the company's handling of this crisis. 🙄 They really have their priorities straight. #sarcasm #fail"
                }
            ]
        }
    ]
)
print(message.content)