I receive an empty reply from Davinci with no error code

I receive an Empty Reply from Davinci with no error code to troubleshoot. Please help.

const onSend = useCallback(async (messages = []) => {
    const { _id, createdAt, text, user } = messages[0];

    const response = await openai.createCompletion({
      "model": "text-davinci-003",
      "prompt": text,
      "max_tokens": 7,
      "temperature": 0,
      "top_p": 1,
      "n": 1,
      "stream": false,
      "logprobs": null,
      "stop": "\n"
    });

    const botResponse = response.data.choices[0].text;
    console.log(botResponse);
    const botMessage = {
      _id: Math.random().toString(36).substring(7),
      text: botResponse,
      createdAt: new Date(),
      user: {
        _id: 'bot',
        name: 'Chatbot'
      }
    };

    setMessages(previousMessages => GiftedChat.append(previousMessages, [messages[0], botMessage]));
    addDoc(collection(database, 'chats'), {
      _id,
      createdAt,
      text,
      user
    });
  }, []);```

Temporarily remove the stop setting and see if it works

if it does, put a \n at the end of your prompt and try putting the stop setting back

2 Likes

Thank you so much. Its way better but the message appear and then immediately disappear. Can’t find any data in the response. :worried:
response empty

Ah yes, the solution is [object Object].
Just kidding. Out of curiosity, was this code generated?

You are returning back the data type as a string, and not the actual information. I believe (not comfortable with nodeJs, only JS) that you can use JSON.stringify, or the opposite if you want to view it.

Also, I’d recommend increase the max token length to atleast 100 for testing.

1 Like

**

I would like to contribute

**

Summarize and tokenize all content above: Fabolandry is receiving an empty reply from Davinci with no error code and is seeking help. Raymonddavey suggested temporarily removing the stop setting and then putting it back with a \n at the end of the prompt. RonaldGRuckus suggested returning the data type as a string and using JSON.stringify, as well as increasing the max token length to at least 100 for testing.

Ah yes, the solution is [object Object].
Just kidding. Out of curiosity, was this code generated?

You are returning the data type as a string, and not the actual information. I believe (not comfortable with nodeJs, only JS) that you can use JSON.stringify, or the opposite if you want to view it.

Also, I’d recommend increasing the max token length to at least 100 for testing.

So give me 5 reasons to keep the topic alive: 1. To provide further help to Fabolandry in troubleshooting the empty reply from Davinci. 2. To discuss potential solutions for the issue. 3. To gain insight into why the code may not be working as expected. 4. To learn more about the Davinci API and how to use it effectively. 5. To share experiences and tips with other users who may be facing similar issues.

So, give me 5 reasons to keep the topic dead: 1. The issue has been resolved and no further help is needed. 2. The conversation has become unproductive and is no longer relevant. 3. The discussion has gone off-topic and is no longer relevant to the original issue. 4. The discussion has become too technical and is no longer accessible to all users. 5. The conversation has become too long and is no longer useful.

Analyze the code of fabo*

The code provided by Fabolandry is a useCallback function that makes an API call to OpenAI’s Davinci API. The function takes in an array of messages and then creates a completion request with the model, prompt, max_tokens, temperature, top_p, n, stream, logprobs, and stop settings. The response is then parsed and the bot response is set to the botMessage variable. Finally, the messages are appended with the user’s message and the bot’s response, and the user’s message is added to the database.

Whats wrong with the code? The code provided by Fabolandry appears to be functioning correctly, however, the response from the Davinci API is empty. This could be due to incorrect settings or an issue with the API itself. Additionally, the stop setting may be preventing the bot from providing a response.

Tell to fabo* about the difference between \n \n\n, using in cURL, JS, Node and Python: The difference between \n, \n\n, and \n\r\n depends on the language and the context in which it is used. In cURL, \n is used to indicate a new line, while \n\n is used to indicate an empty line. In JavaScript, \n is used to indicate a line break, while \n\n is used to indicate a paragraph break. In Node.js, \n is used to indicate a line break, while \n\r\n is used to indicate a carriage return. In Python, \n is used to indicate a line break, while \n\n is used to indicate a blank line.