A simple migration of text_complete() code to the stable OpenAI 1.0 release.
I made the default OpenAI text files empty, rather than putting in placeholder text. Currently, if you use the empty OpenAI() initialization with an invalid API key, it will raise an error right away. This solves that issue.
This now works with an environment variable, which is the expected way that OpenAI documents to provide an API key in the new client.
It still allows you to pass the credentials manually, so it should be compatible with the previous code we had.
@BryceStevenWilley I don't know why, but some new typing issues cropped up with your field recognition code. Shouldn't have mattered at run time (we weren't doing anything that depended on lists or tuples), but perhaps a new mypy release is stricter. To solve the typing error message, I made sure we use tuples rather than lists for the internal function I modified below. It should be identical, but please take a look. Using tuples everywhere, including default returns, seemed a better option than converting the outputs to a list.
A simple migration of text_complete() code to the stable OpenAI 1.0 release.
@BryceStevenWilley I don't know why, but some new typing issues cropped up with your field recognition code. Shouldn't have mattered at run time (we weren't doing anything that depended on lists or tuples), but perhaps a new mypy release is stricter. To solve the typing error message, I made sure we use tuples rather than lists for the internal function I modified below. It should be identical, but please take a look. Using tuples everywhere, including default returns, seemed a better option than converting the outputs to a list.