The api or model is not giving the response as per the prompt

this is my prompt :
prompt = f"“” Write a 70 word paragraph regarding main challenges and risks for elderly living independently in {city} based on unique geography, climate, health, crime, social and recent issues in {city}, and poor relative availability of help for seniors in {city}. Cite best and nearest available or estimated data on percentage of elderly population. Compare with national average. Also mention top chronic health issues especially in view of local conditions , rate of crime, and preference of senior citizens in {city} region and the state it belongs to. Get past population statistics from reliable source and use it proxy for current population. Write the paragraph in the same tone, structure and style as the following paragraph: “Elderly constitute 14% of the population in Agra, higher than national average. Those living independently face numerous challenges and risks. The top three health issues in Agra given its situation are hypertension, diabetes, and depression and many elderly suffer from one or more chronic condition. Also, crime rate in Agra remains high, and many senior citizens in Agra do not have timely access to necessary healthcare and other assistance.” “”"

I use python as a coding language and using openai.Creation.create to generate the response.

Welcome to the OpenAI community @lvetslp

Please share the code making the API call.

Also, I’d recommend using chat completions endpoint for this prompt instead of completions endpoint.

1 Like
prompt = f""" Write a 70 word paragraph regarding main challenges and risks for elderly living independently in {city} based on unique geography, climate, health, crime, social and recent issues in {city}, and poor relative availability of  help for seniors in {city}. Cite best and nearest available or estimated  data on percentage of elderly population. Compare with national average. Also mention top chronic health issues especially in view of local conditions , rate of crime, and preference of senior citizens in {city} region and the state it belongs to. Get past population statistics from reliable source and use it proxy for current population. Write the paragraph in the same tone, structure and style as the following paragraph: "Elderly constitute 14% of the population in Agra, higher than national average. Those living independently face numerous challenges and risks.  The top three health issues in Agra given its situation are hypertension, diabetes, and depression and many elderly suffer from one or more chronic condition. Also, crime rate in Agra remains high, and many senior citizens in Agra do not have timely access to necessary healthcare and other assistance." """
       response = openai.Completion.create(
           # engine="davinci",
           model="gpt-3.5-turbo-instruct",
           prompt=prompt,
           # max_tokens=100,
           api_key=api_key
       )
       # print(city)
       generated_text = response.choices[0].text.strip()
       doc.add_paragraph(generated_text)
       file_name = city+".docx"

That isn’t how you supply the API key.

Please use the boilerplate code provided in API ref

1 Like