Project

General

Profile

Actions

Feature #302

closed

[BE]Apply logic set usable cho key, giảm thiểu bị lỗi rate limit

Added by Nguyen Trong 9 months ago. Updated 8 months ago.

Status:
Closed
Priority:
Normal
Target version:
-
Start date:
12/21/2023
Due date:
% Done:

0%

Estimated time:
Spent time:

Description

Khi apply dịch nhanh thì sẽ phát sinh việc rate limit, do số key có ít.
Nên phải implement task sau đây (làm cùng với cái dịch nhanh):
1. Khi có lỗi ratelimit thì có báo ngày giờ dùng được tiếp, hãy dùng cái đó set usable_at thay cho mặc định + 5 phút như hiện tại.
2. Khi sắp bị rate limit có trả về là còn bao nhiêu requesst nũa sẽ bị rate limit, vậy nếu hết số request có thể được gọi thì set usable_at luôn cho nó, không để request tiếp theo gọi dùng key đó, và phát sinh lỗi.

Nội dung implement

- update openai package version lên 1.6.1
- thêm argument gpt_version vào CRUDOpenaiApiKey deactivate_api_key, set_usable_at
- check reponse ratelimit header sau mỗi request lên openai, nếu remains request = 0 thì set giá trị usable_at tương ứng

Actions

Also available in: Atom PDF