QChatGPT/pkg/provider/runnermgr.py

28 lines
617 B
Python
Raw Normal View History

2024-07-28 18:45:27 +08:00
from __future__ import annotations
from . import runner
from ..core import app
from .runners import localagent
class RunnerManager:
ap: app.Application
using_runner: runner.RequestRunner
def __init__(self, ap: app.Application):
self.ap = ap
async def initialize(self):
for r in runner.preregistered_runners:
if r.name == self.ap.provider_cfg.data['runner']:
self.using_runner = r(self.ap)
await self.using_runner.initialize()
break
def get_runner(self) -> runner.RequestRunner:
return self.using_runner