Below is the python code I have. The output is exactly what I am looking for however I cannot figure out how to put the multiple responses that is printed out by the last line of python code to return back all responses into a new column in a dataframe. I get None values when I have tried in the past. Please help! I am using open.ai and pandas and hoping to export to an excel file.
for question in df['Question']:
response = openai.Completion.create(
model="text-davinci-003",
prompt="Write a detailed, lengthy, and authoratative response to the question: {}".format(question),
temperature=0.7,
max_tokens=20,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
print(response['choices'][0]['text'].strip())
print(response['choices'][0]['text'].strip())
This line gives me the correct output but how do I join these strings and put them in a new column in excel. Stumped!