Skip to content

Commit

Permalink
fix retry config (#757)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZingLix authored Aug 28, 2024
1 parent d3f02f8 commit d0db315
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions python/qianfan/resources/requestor/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ def _request(
resp.statistic["request_latency"] = response.elapsed.total_seconds()
resp.request = QfRequest.from_requests(response.request)
resp.request.json_body = copy.deepcopy(request.json_body)
resp.request.retry_config = request.retry_config

if "X-Ratelimit-Limit-Requests" in resp.headers:
self._rate_limiter.reset_once(
Expand Down Expand Up @@ -382,6 +383,7 @@ async def _async_request(
resp.statistic["request_latency"] = request_latency
resp.request = QfRequest.from_aiohttp(response.request_info)
resp.request.json_body = copy.deepcopy(request.json_body)
resp.request.retry_config = request.retry_config
if "X-Ratelimit-Limit-Requests" in resp.headers:
await self._rate_limiter.async_reset_once(
float(resp.headers["X-Ratelimit-Limit-Requests"])
Expand Down
2 changes: 2 additions & 0 deletions python/qianfan/resources/requestor/openapi_requestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def iter() -> Iterator[QfResponse]:
parsed = self._parse_response(json_body, resp)
parsed.request = QfRequest.from_requests(resp.request)
parsed.request.json_body = copy.deepcopy(request.json_body)
parsed.request.retry_config = request.retry_config
parsed.statistic["first_token_latency"] = resp.elapsed.total_seconds()
yield data_postprocess(parsed)

Expand Down Expand Up @@ -252,6 +253,7 @@ async def iter() -> AsyncIterator[QfResponse]:
parsed = await self._parse_async_response(json_body, resp)
parsed.request = QfRequest.from_aiohttp(resp.request_info)
parsed.request.json_body = copy.deepcopy(request.json_body)
parsed.request.retry_config = request.retry_config
yield data_postprocess(parsed)

return iter()
Expand Down

0 comments on commit d0db315

Please sign in to comment.