openai-python icon indicating copy to clipboard operation
openai-python copied to clipboard

response is truncated from API

Open Mevatlave-Kraspek opened this issue 2 years ago • 6 comments

After pip install openai, I tried:

openai api completions.create -e text-davinci-003 -p "what means soyboy in French?

I get

Le terme « soyboy » n'est pas courant en

The text is not finished/truncated.

What I did wrong? I see no documentation here on how to set tokens from command line if this is the issue there.

Mevatlave-Kraspek avatar Jan 21 '23 06:01 Mevatlave-Kraspek

Ok,

openai api completions.create -e text-davinci-003 -M 1000 -p "what means soyboy in French?"

Mevatlave-Kraspek avatar Jan 21 '23 06:01 Mevatlave-Kraspek

same issue for me with version:0.26.5

jackleeforce avatar Feb 24 '23 08:02 jackleeforce

Could you manage to generate the full response?

hafiz031 avatar Mar 02 '23 03:03 hafiz031

Setting --max_tokens, or -M, from the command line should be the correct way to solve this issue since it looks like the original just needed more tokens. Is that not what others are seeing?

hallacy avatar Mar 07 '23 03:03 hallacy

Setting --max_tokens, or -M, from the command line should be the correct way to solve this issue since it looks like the original just needed more tokens. Is that not what others are seeing?

This is --max-tokens.

hafiz031 avatar Mar 07 '23 04:03 hafiz031

The default value of max_tokens in v1/completions (openai.Completion.create) is 16, which is why you might see the response cut off. This is reflected in the response under choices.finish_reason as length. You can change this value as you please.

athyuttamre avatar Mar 17 '23 20:03 athyuttamre