danicor commited on
Commit
e4fa0cf
·
verified ·
1 Parent(s): 482a899

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py CHANGED
@@ -618,6 +618,36 @@ async def check_translation_status(req: StatusRequest):
618
  # بازگشت همان ساختاری که GET /api/status/{request_id} می‌دهد
619
  return await check_status(req.request_id)
620
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
621
 
622
 
623
  if __name__ == "__main__":
 
618
  # بازگشت همان ساختاری که GET /api/status/{request_id} می‌دهد
619
  return await check_status(req.request_id)
620
 
621
+ @app.get("/api/status")
622
+ async def orchestrator_status():
623
+ available_workers = sum(1 for w in orchestrator.workers.values() if w.available)
624
+ total_workers = len(orchestrator.workers)
625
+ cache_stats = orchestrator.cache.get_stats()
626
+
627
+ # محاسبه درخواست‌ها
628
+ total_requests = sum(w.total_completed + w.total_failed for w in orchestrator.workers.values())
629
+ active_sessions = sum(w.active_jobs for w in orchestrator.workers.values())
630
+
631
+ return {
632
+ "model": "facebook/m2m100_418M", # ثابت
633
+ "device": "multi-worker", # چون چند تا Worker داری
634
+ "total_requests": total_requests,
635
+ "active_sessions": active_sessions,
636
+ "cache_size": cache_stats.get("cache_size", 0),
637
+ "version": ORCHESTRATOR_VERSION,
638
+ "workers": [
639
+ {
640
+ "id": wid,
641
+ "name": w.config.name,
642
+ "url": w.config.url,
643
+ "available": w.available,
644
+ "active_jobs": w.active_jobs,
645
+ "total_completed": w.total_completed,
646
+ "total_failed": w.total_failed,
647
+ }
648
+ for wid, w in orchestrator.workers.items()
649
+ ]
650
+ }
651
 
652
 
653
  if __name__ == "__main__":