对 Reasoning 的再思考
您已经体验了不同的模型,接下来试试视频中介绍的另外两个参数:reasoning 和 max_output_tokens。
挑战如下:
- 使用 LLM 找到问题的正确答案:在句子 "Mississippi are possessive over their successes?" 中有多少个字母 's'? 提前透露:答案是
12。 - 代码必须在 8 秒内运行完成!
您可以使用以下任一模型:gpt-5.4-nano、gpt-5.4-mini 和 gpt-5.5。
本练习是课程的一部分
使用 OpenAI Responses API
练习说明
- 请在 8 秒内 完成本挑战,并且正确找出所给提示的答案!
交互式实操练习
通过完成这段示例代码来试试这个练习。
start_time = time.time()
prompt = "How many of the letter 's' are in the sentence, 'Mississippi are possessive over their successes?'"
# Complete the challenge!
response = client.responses.create(
____
)
runtime = time.time() - start_time
print(response.output_text)
print(f"\nRuntime: {runtime:.2f} seconds")