OpenAI gpt-3.5-turbo:請求失敗,狀態代碼 400
P粉546138344
P粉546138344 2023-09-01 12:17:58
0
1
492
<p>node.js 中的這個方法不再運作了嗎?因為當時它工作正常,但現在它不再工作了,而且此程式碼也基於他們的官方文檔,即 https://platform.openai.com/docs/api-reference/completions/create</ p> <p><strong>我的伺服器端程式碼:</strong></p> <pre class="brush:js;toolbar:false;"> import { Configuration, OpenAIApi } from 'openai'; //.... const configuration = new Configuration({ apiKey: API_KEY, }); //.... const openai = new OpenAIApi(configuration); //.... const response = await openai.createChatCompletion({ model: "gpt-3.5-turbo", messages: [ { role: "system", content: `You are a helpful assistant.` }, ...prompt ], temperature: 0.2, max_tokens: 1500, top_p: 1, frequency_penalty: 0, presence_penalty: 0, }); //.... res.status(200).send({ bot: response.data.choices[0].message.content }); //.... </pre> <p><strong>我嘗試發送的資料:</strong></p> <pre class="brush:json;toolbar:false;">{ "prompt": [ { "role": "bot", "content": "Something went wrong." }, { "role": "user", "content": "What is wrong?" } ] } </pre> <p><strong>我遇到了這個錯誤:</strong> | 訊息提示的輸出位於終端機中,以防您想檢查我是否發送了正確的訊息提示。 </p> <p>我還嘗試添加組織 ID,但仍然不起作用,也嘗試將其從 v3.2.1 更新到 v3.3.0,但根本不起作用。我的帳戶裡還有餘額。 </p>
P粉546138344
P粉546138344

全部回覆(1)
P粉267791326

問題已解決,我發送了錯誤的角色而不是機器人,它應該是助理。所以這種格式將使一切恢復正常:

{
  "prompt": [
    {
      "role": "assistant",
      "content": "Something went wrong."
    },
    {
      "role": "user",
      "content": "What is wrong?"
    }
  ]
}

基於https://platform.openai.com/docs/api -reference/chat/create 只有4 個角色:systemuserassistantfunction代码>

#
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!