#Long form article

17 messages · Page 1 of 1 (latest)

little laurel
#

hi all, I'm trying to figure out what's the best way to obtain (even with multiple calls in the same script) an article of at least 1000 words. Could anyone give me some advice, point me in the right direction?

fiery charm
#

Hi @little laurel its better if you apply divide and conquer approach
first generate subheadings from title, and then send separate request for each subheading with a prompt for text generation, it might not be good for starters, but with time you can improve results

little laurel
#

Thanks for the reply @fiery charm . I just have to figure out how to wait for the first completion with subheadings and then send the second prompt. Do you have any code examples in python to show me?

fiery charm
#

@little laurel normally openAI calls are blocking calls, so whenever you hit completion API, it is going to wait till it get response.
you can do something similar to this
def generate(prompt):
response = openai.Completion.create(
model=model,
prompt = prompt,
temperature=temperature,
max_tokens=max_tokens,
frequency_penalty=frequency_penalty,
presence_penalty=presence_penalty
)
return response.choices[0].text
outline_prompt = 'given the article name, generate outline/headings of the article'

outline = generate(outline_prompt).lstrip().rstrip()

outline = outline.split('\n')
article = f'{article_title}'
for heading in outline:
prompt = f'given article title and heading, generate content for the given heading\n{heading}'
content = generate(prompt).lstrip().rstrip()
article+= heading
article+='\n'
artice+=content
print (article)

#

@little laurel the code might look bad can explain it, just wrote it and it isn't tested as of now

#

what I'm doing is, first I generate outline of the article based on book name, then I use the outline as headings and generate content for the given heading, and add them in a string which is supposed to be my article

little laurel
#

Wow thank you! Yes clear, I will test it right away and let you know. You have been very kind. THANK YOU

little laurel
#

@fiery charm A few small changes to fit my script and it works perfectly! Thanks again. Unfortunately I am having this problem 😦 ---> openai.error.RateLimitError: The server had an error while processing your request. Sorry about that! It seems to be a common problem

fiery charm
#

I do understand the issue, trying to solve it on my end at the moment

#

can you tell me about your account

#

are you paying for that or are you or free trial?

little laurel
#

paying

fiery charm
#

check this notebook out

#

it contains a lot of info about why we face this error and ways to solve it

little laurel
#

I take a look at it

little laurel
#

It seems to be working now. However, the subtitles it generates are not consistent with the title. I'll try editing the prompts