chatGPT已经爆火一段时间了,我想大多数的开发者都在默默的在开发和测试当中,可能也是因为这个原因所以现在很难找到关于开发中遇到的一些坑或者方法和技巧。
为什么别人的机器人能联想之前的语料,而你的却像个每次都只如初见的高冷机器人?
我也是参考官方文档去阅读和理解的,但是有时候官方文档以为你很懂了,就没有太多说明,废话不多说下面我跟大家讲一下API调用时如何启用上下文管理的。
官方案例:
# Note: you need to be using OpenAI Python v0.27.0 for the code below to work
import openai
openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who won the world series in 2020?"},
{"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."},
{"role": "user", "content