Incomplete or truncate result

Hello, I am using the following API call but the result is incomplete or truncated. I get results like this:

#NorthKorea-linked #LazarusGroup transfers $63.4M in #Ethereum from #2022HarmonyBridge hack to #crypto exchanges. Funds frozen, 124 $BTC recovered. Attack is part of a larger #crypto theft operation totaling

API call:

    const response = await this.openai.createCompletion({
      model: 'text-davinci-003',
      prompt:
        'Create an objective summary news from this article with less than 260 characters including spaces:\n' +
        text +
        '\n',
      temperature: 0.7,
      max_tokens: 65,
      top_p: 1.0,
      frequency_penalty: 0.0,
      presence_penalty: 0.0
    });```

How can I improve it?

I think I will be right in saying that your max_tokens is way to low for what you are doing.

You need tokens that accommodate input and output. Tokens equate crudely to 1 per every 4 letters.

A high max_tokens will not cause them to be consumed unless they are used. And they are a generally a fraction of a cent per 1000.

2 Likes

Thanks for the answer. do you know how I can get the result in more than 260 characters? The result is bigger.

Just as @paul.armstrong said: set a higher max_tokens.

    const response = await this.openai.createCompletion({
      model: 'text-davinci-003',
      prompt:
        'Create an objective summary news from this article with less than 260 characters including spaces:\n' +
        text +
        '\n',
      temperature: 0.7,
      max_tokens: 1000,
      top_p: 1.0,
      frequency_penalty: 0.0,
      presence_penalty: 0.0
    });```

Sorry, the result I what to be less than 260. I wrote “more than” by mistake.

Something like this?

[TASK: Create a short, objective summary from this article.\nLENGTH: less than 260 characters including spaces.]