InvalidRequestError during query from text file

I am using the openapi API to query a text file but I get the following error

INFO:openai:error_code=None error_message=“[‘’] is not valid under any of the given schemas - ‘input’” error_param=None error_type=invalid_request_error message=‘OpenAI API error received’ stream_error=False

What could be the problem


It is hard to say that only based on the Error message. By sharing the input you’ve send this would help to see where some Issues might lie.

Also this is the #chatgpt Category, by changing the category to #general-api-discussion you might get better replies due to some people only focusing on the categories theyre interested in :wink:

This is the complete code that I am using,

def construct_index(directory_path):
max_input_size = 4096
num_outputs = 512
max_chunk_overlap = 20
chunk_size_limit = 600

prompt_helper = PromptHelper(max_input_size, num_outputs, max_chunk_overlap, chunk_size_limit=chunk_size_limit)
llm_predictor = LLMPredictor(llm=OpenAI(temperature=0.7, model_name="text-davinci-003", max_tokens=num_outputs))
documents = SimpleDirectoryReader(directory_path).load_data()
vectorindex = GPTSimpleVectorIndex(documents, llm_predictor=llm_predictor, prompt_helper=prompt_helper)
return vectorindex

vectorindex = construct_index(“C:\temp\ChatGPT/swim.txt”)

def answerMe(vectorindex):
vIndex = GPTSimpleVectorIndex.load_from_disk(vectorindex)
while True:
question = input(‘Please Ask:’)
response = vIndex.query(question, response_mode=“compact”)
print(f"Response: {response} \n")