File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed
Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -47,10 +47,25 @@ async def refresh_workers():
4747
4848def get_next_worker (model : str = "" ) -> Optional [dict ]:
4949 cache = _worker_cache
50- available = cache ["workers" ]
51- if not available :
50+ workers = cache ["workers" ]
51+ if not workers :
5252 return None
53- worker = available [cache ["index" ] % len (available )]
53+
54+ candidates = workers
55+ if model :
56+ current_time = time .time ()
57+ candidates = []
58+ for w in workers :
59+ limits = w .get ("rate_limited_models" , {})
60+ if model in limits :
61+ if limits [model ] > current_time :
62+ continue
63+ candidates .append (w )
64+
65+ if not candidates :
66+ return None
67+
68+ worker = candidates [cache ["index" ] % len (candidates )]
5469 cache ["index" ] += 1
5570 return worker
5671
You can’t perform that action at this time.
0 commit comments