#Response is blank

1 messages · Page 1 of 1 (latest)

warm plinth
#

Hi im trying to generate a response but its being blank the prompt is given but the response is either undefinded or blank quotes. idk what to do. javascript

ebon roseBOT
#

Hi @warm plinth. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

There could be several reasons why you're getting a blank or undefined response from the OpenAI API. Here are a few things you could check:

  1. Check your prompt: Make sure the prompt you're passing to the API is correctly formatted and contains valid content. The prompt is the input that you give to the model to generate a response.

  2. Check your API call: Ensure that you're making the API call correctly. Here's an example of how to make an API call using the OpenAI Node.js SDK:

const response = await openai.createChatCompletion({
    model: "gpt-4-32k-0314",
    messages: [
      {
        role: "system",
        content: system,
      },
      {
        role: "user",
        content: `${user}`,
      },
    ],
    temperature: 0.3,
    frequency_penalty: 0.7,
    presence_penalty: 0.7,
    stream: true,
    max_tokens: 3500,
});

(Source: Forum Post: Api call to gpt-4-32k or gpt-4 allucinate at the end of long responses > Original post Part 1 (https://community.openai.com/t/646316))

  1. Check your model: Make sure you're using a valid model. The model name should be passed as a string to the model parameter in the API call. For example, "gpt-4-32k-0314".

  2. Check your API key: Ensure that your OpenAI API key is correctly set in your environment variables and that it has the necessary permissions.

  3. Check the API response: The response from the API call should be an object that contains the generated text. You can access this text using response.choices[0].message.content for chat models.

If you're still having trouble, it would be helpful to see the exact code you're using to make the API call, as well as the full response you're getting from the API.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: