如何将多个系统提示嵌入到我的聊 bot 中?

我正在使用openai,并在我的消息中定义系统提示。

如果我想添加多个系统提示,比如以下内容:

  1. 你的回答必须限制在两行之内
  2. 你的回答不得粗鲁
  3. 根据查询的语言,你的回答必须使用英语或德语

我该如何将这些系统提示整合到下面的代码中呢?

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

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注