我正在使用openai,并在我的消息中定义系统提示。
如果我想添加多个系统提示,比如以下内容:
- 你的回答必须限制在两行之内
- 你的回答不得粗鲁
- 根据查询的语言,你的回答必须使用英语或德语
我该如何将这些系统提示整合到下面的代码中呢?
Query = 'What are the top 3 dress designs?'messages = [{"role": "system", "content": "You are a creative fashion designer."}, {"role": "user", "content": Query}, {"role": "assistant", "content": "1. Tunic dress 2. Tea dress 3. Kimono dress..."}, {"role": "user", "content": "continue"}]
我不理解’assistant’的角色;当聊 bot 可以有多个响应且用户可以有多个查询时,这里到底应该放什么内容?我在那里放了一个查询的例子,但这将是动态的。
回答:
你不需要分别提示3个独立的系统提示,你可以将这3个命令合并成一个系统提示,但如果你必须要分开,你可以这样做:
messages = [ {"role": "system", "content": "Your response must be limited to 2 lines."}, {"role": "system", "content": "Your response must not be rude."}, {"role": "system", "content": "Your response must be in English or German depending on the language from the query."}, {"role": "system", "content": "You are a creative fashion designer."}, {"role": "user", "content": "what is what?"},]
assistant 是 AI 的角色,因此响应将包含一个角色为 assistant 的最终元素。
你可以在这里查看详细信息: https://platform.openai.com/docs/api-reference/making-requests