3

I'm trying to use the OpenAI beta but I can't seem to get a result. I'm accessing the API via an NPM package (https://www.npmjs.com/package/openai-api). I have that setup and working but when I make a request the response I'm getting is missing any content in the response object.

Here's my code

const suggestedDescription = await openai.complete( {
        engine: 'davinci',
        prompt: metadata.description,
        maxTokens: 20,
        temperature: 0,
        topP: 1,
        presencePenalty: 0,
        frequencyPenalty: 0,
        stop: ['...']
      } );

The resulting object looks like this:

suggestedDescription { text: '', index: 0, logprobs: null, finish_reason: 'stop' }

Any thoughts?

0

1 Answer 1

2

don't use openai-api anymore, it's not supported officially. use npm i openai instead.

Code example would be something like this:

export const askOpenAi = async () => {
const prompt = `input: What is human life expectancy in the United States?
output:`
const response = await openai.createCompletion("text-davinci-001", {
    prompt: prompt,
    temperature: 0,
    max_tokens: 100,
    top_p: 1,
    frequency_penalty: 0,
    presence_penalty: 0,
    stop: ["input:"],
});
return response.data;
}
Sign up to request clarification or add additional context in comments.

1 Comment

hi can u explain temperature: 0, max_tokens: 100, top_p: 1, frequency_penalty: 0, presence_penalty: 0, stop: ["input:"], Thanks so much

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.