Insert caching and logging directly into the OpenAI package source.
Patch the source:
python -m patch
This will:
- Find the
request
method and insert arequest_without_cache
method and arequest_with_cache
replacement. - Cache all invocations int
/cache
folder, unlessstream=True
. - Cache all request and response data, including API key.
Undo changes:
python -m restore
This will restore a backup of the original source file.
MIT