base.py 937 B

1234567891011121314151617181920212223242526272829303132333435
  1. # base implementation of the scheduler, sets up the threads and init
  2. # which all sub classes will inherit and wouldn't need to change.
  3. from threading import Thread
  4. from aios.llm_core.llms import LLM
  5. from aios.utils.logger import SchedulerLogger
  6. class BaseScheduler:
  7. def __init__(self, llm: LLM, log_mode):
  8. self.active = False # start/stop the scheduler
  9. self.log_mode = log_mode
  10. self.logger = self.setup_logger()
  11. self.thread = Thread(target=self.run)
  12. self.llm = llm
  13. def run(self):
  14. pass
  15. def start(self):
  16. """start the scheduler"""
  17. self.active = True
  18. self.thread.start()
  19. def setup_logger(self):
  20. logger = SchedulerLogger("Scheduler", self.log_mode)
  21. return logger
  22. def stop(self):
  23. """stop the scheduler"""
  24. self.active = False
  25. self.thread.join()
  26. def execute_request(self, agent_process):
  27. pass