Term Cleanup: Handle embedding generation errors like rate limits

Abierto
#906 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
45/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
php, wordpress
Área
ai, backend

Línea de trabajo

El issue no nombra archivos ni tests; primero localiza el flujo de cleanup que genera embeddings e inspecciona cómo se gestionan actualmente las respuestas de la API y los fallos de rate limit. Se considera terminado cuando los errores generales de la API se detienen con un mensaje visible, mientras que las respuestas de rate limit reintentan con un backoff acotado o finalmente se detienen con un error, respaldado por tests para ambos caminos.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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
Lenguaje dominante
PHP
Estrellas
714
Forks
68
Merge medio
4 h 32 min
PR fusionados (30 d)
23

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de 10up/classifai

Todos los issues de 10up/classifai

Issues similares

Más issues de PHP

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.