This happens to probably 10% of responses I get. For whatever reason, the last bits of my prompt somehow spill into it, at the start of it. Like there will be a period, or a question mark, or sometimes a few of the last letters from the prompt, that get removed from the prompt, and somehow find their way into BOTH the response that gets printed inside of the Visual Studio Code terminal, AND in the outputted version that gets written to a corresponding Excel spreadsheet.
Any reason why this might happen?
Some example responses:
.
Most apples are colored red.
Also
?
Most rocks are colored gray.
Another example:
for it.
Most oceans are colored blue.
The period, the question mark, " for it" somehow get transposed FROM the end of the prompt, and tacked onto the response. And they even get removed from the prompt that was originally in the Excel spreadsheet to begin with.
Could this be a bug with xlsxwriter? open ai? Some combo of both?
Code here:
import xlsxwriter
import openpyxl
import os
import openai
filename = f'testing-openai-gpt3-requests-v1.xlsx'
wb = openpyxl.load_workbook(filename, read_only=False)
sheet = wb.active
# print("starting number of ideas is:")
# print(sheet.max_row)
for x in range(sheet.max_row):
c = sheet.cell(row = x+1, column = 1)
# print(c.value)
myCurrentText = c.value
myCurrentPrompt = "What is the color of most of the following objects: " + myCurrentBusinessIdea
openai.api_key = [none of your business]
response = openai.Completion.create(
model = "text-davinci-003",
prompt = myCurrentPrompt,
max_tokens = 1000,
)
TheOutputtedSummary = response['choices'][0]['text']
print(TheOutputtedSummary)
sheet.cell(row = x+1, column = 6).value = TheOutputtedSummary
wb.save(str(filename))
print('All finished!')