AnswerDotAI / rerankers

A lightweight, low-dependency, unified API to use all common reranking and cross-encoder models.
Apache License 2.0
1.09k stars 60 forks source link

API rate limiting #33

Open ScotterC opened 1 month ago

ScotterC commented 1 month ago

This could be added to the api models by interpreting response headers or maybe an option given to Reranker which limits the amount of requests per min.

For instance, Jina when not on premium is 60 rpm. Cohere is 10 rpm on trial key and 1000 rpm on production key

bclavie commented 1 month ago

This could be useful yes!

I'd see an optional "max_requests_per_minute" argument to the loading an API reranker, along with a retries_on_failure: int and max_time_between_retries parameters which would specify the max number of retries? Either (or both) being set would result in:

These would be optional and most likely default to:

Is this something you'd be interesting in contributing a PR for? Otherwise I'll add it to the to-do as a low priority item!

ScotterC commented 6 days ago

Sorry, I've moved on from this particular need but I could imagine forking/working on it in the future if it becomes a blocker. Better off categorizing as a low-pri item on your end 👍