Using OAI to run an extraction job on scraped web pages, and I’m getting this error recently.
‘error’: {‘message’: “Sorry! We’ve encountered an issue with repetitive patterns in your prompt. Please try again with a different prompt.”, ‘type’: ‘invalid_request_error’, ‘param’: ‘prompt’, ‘code’: ‘invalid_prompt’}}
I’m using GPT3.5 and there’s nothing in the community docs which points to a fix.
I haven’t seen that type of error in quite a while. Can you share the prompt you called it with? Typically the issue is fairly easy to spot and resolve.
The error will depend on the input, and how many identical tokens or token sequences are in the total input. In this case, the content of the page.
Snippet to get this error, where the threshold is 200 repeats of the same 2-token or 3-token welcome message.
from openai import OpenAI
client = OpenAI()
system = [{"role": "system", "content": "assistant is a helpful expert."}]
user = [{"role": "user", "content": "Hello AI\n"*201}]
chat = []
while not user[0]['content'] == "exit":
response = client.chat.completions.create(
messages = system + chat[-10:] + user,
model="gpt-3.5-turbo",
top_p=0.9, stream=True, max_tokens=512)
reply = ""
for delta in response:
if not delta.choices[0].finish_reason:
word = delta.choices[0].delta.content or ""
reply += word
print(word, end ="")
chat += user + [{"role": "assistant", "content": reply}]
user = [{"role": "user", "content": input("\nPrompt: ")}]
The five tokens of "content": "Hello there, buddy! " * 1000 returns no error, curiously, so the repetition will likely need to be on the short side for detection and error.
It seems like you repeated the phrase “Hello there, buddy!” approximately 300 times. That’s quite a lot of hellos! How can I assist you today?