packagecom.owlmaddie.utils;importjava.util.concurrent.Semaphore;importjava.util.concurrent.Executors;importjava.util.concurrent.TimeUnit;/** * The {@code RateLimiter} class is used to slow down LLM unit tests so we don't hit any rate limits accidentally. */publicclassRateLimiter{privatefinalSemaphoresemaphore;publicRateLimiter(intrequestsPerSecond){semaphore=newSemaphore(requestsPerSecond);Executors.newScheduledThreadPool(1).scheduleAtFixedRate(()->{semaphore.release(requestsPerSecond-semaphore.availablePermits());},0,1,TimeUnit.SECONDS);}publicvoidacquire()throwsInterruptedException{semaphore.acquire();}}