Improve error message for stop word > 4 sequences

Hey,

I never knew why more than 4 stop words would fail with a strange message

Error: “[‘\\n###\\n’, ‘###’, ‘\\n’, ’ ### ', ‘[[’, ‘—’] is not valid under any of the given schemas - ‘stop’”

I’d suggest something like “Up to 4 sequences are allowed as stop word argument”
As it is clearly written here:
https://beta.openai.com/docs/api-reference/completions/create#completions/create-stop

3 Likes

Very good point.
I had the same error thrown and had to try several use cases before figuring out that there was a length limit to the list of stops.

It could also be mentioned in the “best practices” of the guide. OpenAI API

I can’t believe I’m running into the same issue in 2024! Why limit number of stop sequences to 4?