#What do you mean by closing a connection

14 messages · Page 1 of 1 (latest)

real granite
#

yeah, but it seems that HTTP connection is not closed after that

junior cloak
#

That wouldn't give you older response though, you'd just timeout as the issue says. What does the code around your request look like?

real granite
#

What I do:

I have a list of keywords and I generate blog posts in a loop. I do it like that:

Generate title - > Generate outline - Generate body, generate intro, generate, conclusion and then move to next keyword

Sometimes (like 20% of the time) article body is added to incorrect title, keyword.

My code is pretty simple, I make simple requests like this:

                model="text-davinci-003",
                prompt=intro_prompt,
                temperature=0.7,
                max_tokens=300,
                top_p=1.0,
                best_of=2,
                frequency_penalty=1.5,
                presence_penalty=1.5,
                stop=["Conclusion"]

            )
            intro = intro_section['choices'][0]['text']
junior cloak
#

I meant more of the error handling in case the request fails

real granite
#

I retry 5 times, if it still fails I move to next keyword

junior cloak
#

Mainly trying to figure out what would be causing the outdated/previous responses

real granite
#

yeah so I do this

  for i in range(5):
                try:
openai.aiosession.set(ClientSession())
                            paragraph_prompt = "I need you to act as a web developer who is writing about " + title_clean + ". Use the following outline and expand in an extensive and detailed matter, make it as long as possible. Change H1 to H2 and if necessary fix headings hierarchy. Follow the outline, do not write introduction and conclusion. Write in french. Format in markdown. Outline: " + outline_full_to_string + "\n",
                            content_section = await openai.Completion.acreate(
                                    model="text-davinci-003",
                                    prompt=paragraph_prompt,
                                    temperature=0.7,
                                    max_tokens=2500,
                                    top_p=1.0,
                                    # best_of=2,
                                    frequency_penalty=0.0,
                                    presence_penalty=1.5
                            )
                            body = content_section['choices'][0]['text']


                except Exception:
                    logging.exception("An exception generating article body was thrown!")
                    time.sleep(1)
                    continue
junior cloak
#

If there isn't missing code between setting body and the exception try setting body inside the except to a message that would indicate failure

real granite
#

I added async just now, trying to figure out if closing connection this way would help in my case

#

nice! Will try that

junior cloak
#

That'll likely be the cause, body doesn't change with that if you error and is scoped outside that chunk so it won't reset every loop

real granite
#

thank you so much! I am just starting with Python and you just saved me hours of trying to figure this out