Term Cleanup: Handle embedding generation errors like rate limits

オープン
#906 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
php, wordpress
領域
ai, backend

調査の方向性

issue にはファイルやテストの名前が記載されていないため、まず embeddings を生成する cleanup フローを特定し、API レスポンスと rate-limit エラーが現在どのように処理されているかを確認する。一般的な API エラーが表示可能なメッセージとともに停止し、rate-limit レスポンスについては上限のある backoff で再試行するか、最終的にエラーで停止することを、両方のパスのテストで裏付けられれば完了とする。

索引モデルが issue の本文から書いたものです。

説明

Is your enhancement related to a problem? Please describe.

Originally documented by @dkotter:

I didn't run into any errors when testing but in looking at the code, it doesn't seem we ever look at the response from generating an embedding.

So in a scenario where this API request fails, we just continue on to the next term. Think of a situation where the API goes down or we hit rate limits on the API. In that case, the process will continue to try forever even though we aren't getting any results from the API.

I'd suggest, if easy enough, two different approaches:

  1. If we get just a general error response from the API (i.e. the API is down), I think we should show that error message and stop the process from continuing
  2. If we get a rate limit error, ideally we would pause for a minute or two before proceeding and then try again. If it fails again with a rate limit error, maybe increase our pause by a couple minutes. Once we've tried this a few times, we can then output an error and stop the process. So basically an automatic retry mechanism with a built-in backoff mechanic to try and handle rate limit issues.

Note this last piece may be overkill for this so we can discuss whether it's worth the effort or not.

Designs

Originally documented by @dkotter:

Note that OpenAI exposes some headers around rate limits that would be interesting to use: https://platform.openai.com/docs/guides/rate-limits/rate-limits-in-headers

They also provide some examples (in python) on how to build an exponential backoff system: https://platform.openai.com/docs/guides/rate-limits/retrying-with-exponential-backoff

Describe alternatives you've considered

Originally reported via https://github.com/10up/classifai-cleanup/issues/3

Code of Conduct
  • I agree to follow this project's Code of Conduct
主要言語
PHP
スター
714
フォーク
68
平均マージ
4時間 32分
マージ済み PR(30日)
23

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

10up/classifai のほかの issue

10up/classifai の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。