-
Notifications
You must be signed in to change notification settings - Fork 477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support openai>=1.1.2 #1260
Support openai>=1.1.2 #1260
Conversation
18d8719
to
4702796
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some small removal
4702796
to
4b08b0d
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1260 +/- ##
==========================================
+ Coverage 80.33% 80.65% +0.31%
==========================================
Files 95 97 +2
Lines 6602 6689 +87
==========================================
+ Hits 5304 5395 +91
+ Misses 1298 1294 -4
☔ View full report in Codecov by Sentry. |
f'{CASSETTE_DIR}/test_batch_translate_async.yaml', | ||
filter_headers=['authorization'], | ||
) | ||
@vcr.use_cassette() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this meta-data?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created
vcr = vcr.VCR(
path_transformer=lambda x: x + '.yaml',
match_on=('method', 'path'),
filter_headers=['authorization'],
cassette_library_dir=CASSETTE_DIR,
before_record_request=before_record_request,
before_record_response=before_record_response,
)
to handle this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha -- gotcha -- I missed that. This is nice.
# monkey patch vcr to make it work with upload binary data | ||
def _make_vcr_request(httpx_request, **kwargs): | ||
from vcr.request import Request as VcrRequest | ||
|
||
try: | ||
body = httpx_request.read().decode("utf-8") | ||
except UnicodeDecodeError: | ||
body = str(httpx_request.read()) | ||
uri = str(httpx_request.url) | ||
headers = dict(httpx_request.headers) | ||
return VcrRequest(httpx_request.method, uri, body, headers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the latest version, when vcr decodes the uploaded binary file, an error occurs. We need to patch it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will get a error on decode
for the binary data
''' | ||
VCR filter function to only record the PNG signature in the response. | ||
|
||
This is necessary because the response is a PNG which can be quite large. | ||
''' | ||
if 'body' not in response: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the latest version, some responses lack the body
field, which will cause an error in the following logic.
Description
#1261
Related Issues
Checklist
make test
successfully?Additional Notes or Comments