🚀 在我们的新课程中掌握提示工程和构建 AI 代理!使用 PROMPTING20 享受 8 折优惠 ➜ 立即注册
添加奇数

使用 LLM 添加奇数

背景

此提示通过让 LLM 检查奇数相加是否为偶数来测试其数学能力。我们还将在此示例中利用思维链提示。

提示

The odd numbers in this group add up to an even number: 15, 32, 5, 13, 82, 7, 1. 
Solve by breaking the problem into steps. First, identify the odd numbers, add them, and indicate whether the result is odd or even. 

代码 / API

from openai import OpenAI
client = OpenAI()
 
response = client.chat.completions.create(
model="gpt-4",
messages=[
    {
    "role": "user",
    "content": "The odd numbers in this group add up to an even number: 15, 32, 5, 13, 82, 7, 1. \nSolve by breaking the problem into steps. First, identify the odd numbers, add them, and indicate whether the result is odd or even."
    }
],
temperature=1,
max_tokens=256,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)

参考资料