搜尋

首頁  >  問答  >  主體

OpenAI gpt-3.5-turbo:請求失敗,狀態代碼 400

<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粉546138344P粉546138344555 天前660

全部回覆(1)我來回復

  • P粉267791326

    P粉2677913262023-09-02 00:12:30

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

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

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

    #

    回覆
    0
  • 取消回覆