API not working?

I amusing this method of query (answers)

openai.Answer.create(
  search_model="ada", 
  model="curie",
  question="which puppy is happy?", 
  documents=["Puppy A is happy.", "Puppy B is sad."],
  examples_context="In 2017, U.S. life expectancy was 78.6 years.", 
  examples=[["What is human life expectancy in the United States?","78 years."]],
  max_tokens=5,
  stop=["\n", "<|endoftext|>"],
)

But instead of documents, I am putting a fileID
but here is my problem which I do not think I am in the wrong.

Successful Query

openai.Answer.create(
  search_model="ada", 
  model="ada",
  question="Which Puppy is happy?", 
  file="file-XQmVUQ0Gxi6anBIdioCcSuaf",
  examples_context="In 2017, U.S. life expectancy was 78.6 years.", 
  examples=[["What is human life expectancy in the United States?","78 years."]],
  max_tokens=5,
  stop=["\n", "<|endoftext|>"],
)
<OpenAIObject answer at 0x27de7e38af0> JSON: {
  "answers": [
    "Puppy is happy."
  ],
  "completion": "cmpl-3UtyWZ4FpQI82P8WeglAeuV7xQ8aT",
  "file": "file-XQmVUQ0Gxi6anBIdioCcSuaf",
  "model": "ada:2020-05-03",
  "object": "answer",
  "search_model": "ada:2020-05-03",
  "selected_documents": [
    {
      "document": 0,
      "object": "search_result",
      "score": -33.798,
      "text": "Research Projects Dementia Detection via Video Detect diseases such as dementia using iPhone Camera which required detection using smaller models using CNNs and Object detectors. Trained on 200GB of image data to detect gazes which is used in detecting dementia. Implemented in Android and iPhone devices as an App. (Python, Tensorflow, Keras, OpenCV, Docker and XML)"
    }
  ]
}

Unsuccessful Query

 openai.Answer.create(
  search_model="ada", 
  model="ada",
  question="What is his phone number?", 
  file="file-XQmVUQ0Gxi6anBIdioCcSuaf",
  examples_context="In 2017, U.S. life expectancy was 78.6 years.", 
  examples=[["What is human life expectancy in the United States?","78 years."]],
  max_tokens=5,
  stop=["\n", "<|endoftext|>"],
)
---------------------------------------------------------------------------
InvalidRequestError                       Traceback (most recent call last)
<ipython-input-46-2d757d9afef1> in <module>
      7   examples=[["What is human life expectancy in the United States?","78 years."]],
      8   max_tokens=5,
----> 9   stop=["\n", "<|endoftext|>"],
     10 )

D:\Anaconda\envs\Tensorflow2\lib\site-packages\openai\api_resources\answer.py in create(cls, **params)
     12     def create(cls, **params):
     13         instance = cls()
---> 14         return instance.request("post", cls.get_url("answers"), params)

D:\Anaconda\envs\Tensorflow2\lib\site-packages\openai\openai_object.py in request(self, method, url, params, headers, stream, plain_old_data)
    242         )
    243         response, stream, api_key = requestor.request(
--> 244             method, url, params, headers, stream=stream
    245         )
    246 

D:\Anaconda\envs\Tensorflow2\lib\site-packages\openai\api_requestor.py in request(self, method, url, params, headers, stream)
    130             method.lower(), url, params, headers, stream=stream
    131         )
--> 132         resp = self.interpret_response(rbody, rcode, rheaders, stream=stream)
    133         return resp, stream, my_api_key
    134 

D:\Anaconda\envs\Tensorflow2\lib\site-packages\openai\api_requestor.py in interpret_response(self, rbody, rcode, rheaders, stream)
    356             )
    357         else:
--> 358             return self.interpret_response_line(rbody, rcode, rheaders, stream)
    359 
    360     def interpret_response_line(self, rbody, rcode, rheaders, stream=False):

D:\Anaconda\envs\Tensorflow2\lib\site-packages\openai\api_requestor.py in interpret_response_line(self, rbody, rcode, rheaders, stream)
    376         if stream_error or not 200 <= rcode < 300:
    377             raise self.handle_error_response(
--> 378                 rbody, rcode, resp.data, rheaders, stream_error=stream_error
    379             )
    380 

InvalidRequestError: No similar documents were found in file with ID 'file-XQmVUQ0Gxi6anBIdioCcSuaf'.Please upload more documents or adjust your query.

Document not found… I just used the document earlier for the “which puppy is happy”.
The document itself is a proper JSONL file which I have double checked it.
The format in the JSONL file is {“text”:“text inside here”}

1 Like

I am not sure but I think in Python that is allowed.
And if you look into the Successful one too there is also a comma.


So I think that is not causing the problem

1 Like

Nope, not a single word that matched “Which Puppy is happy?”
the error is with the file, which is the odd part!

1 Like

Sorry, I do not get your question.

If you are talking about how there is no

something = openai.answers.create(vals)

then you are mistaken, the code was ran on Jupyter lab so even without the something= it will work!!

1 Like

But the error says file not found.
But the question has my answer in the document.