mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-02 03:55:55 +00:00
feat: 热更新和热重载功能
This commit is contained in:
34
pkg/openai/modelmgr.py
Normal file
34
pkg/openai/modelmgr.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# 提供与模型交互的抽象接口
|
||||
|
||||
COMPLETION_MODELS = {
|
||||
'text-davinci-003'
|
||||
}
|
||||
|
||||
EDIT_MODELS = {
|
||||
|
||||
}
|
||||
|
||||
IMAGE_MODELS = {
|
||||
|
||||
}
|
||||
|
||||
|
||||
# ModelManager
|
||||
# 由session包含
|
||||
class ModelMgr(object):
|
||||
|
||||
using_completion_model = ""
|
||||
using_edit_model = ""
|
||||
using_image_model = ""
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def get_using_completion_model(self):
|
||||
return self.using_completion_model
|
||||
|
||||
def get_using_edit_model(self):
|
||||
return self.using_edit_model
|
||||
|
||||
def get_using_image_model(self):
|
||||
return self.using_image_model
|
||||
0
pkg/utils/__init__.py
Normal file
0
pkg/utils/__init__.py
Normal file
19
pkg/utils/reloader.py
Normal file
19
pkg/utils/reloader.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import logging
|
||||
|
||||
import pkg
|
||||
import importlib
|
||||
import pkgutil
|
||||
|
||||
|
||||
def walk(module, prefix=''):
|
||||
for item in pkgutil.iter_modules(module.__path__):
|
||||
if item.ispkg:
|
||||
walk(__import__(module.__name__ + '.' + item.name, fromlist=['']), prefix + item.name + '.')
|
||||
else:
|
||||
logging.info('reload module: {}'.format(prefix + item.name))
|
||||
importlib.reload(__import__(module.__name__ + '.' + item.name, fromlist=['']))
|
||||
|
||||
|
||||
def reload_all():
|
||||
walk(pkg)
|
||||
importlib.reload(__import__('config'))
|
||||
7
pkg/utils/updater.py
Normal file
7
pkg/utils/updater.py
Normal file
@@ -0,0 +1,7 @@
|
||||
def update_all():
|
||||
try:
|
||||
from dulwich import porcelain
|
||||
repo = porcelain.open_repo('.')
|
||||
porcelain.pull(repo)
|
||||
except ModuleNotFoundError:
|
||||
raise Exception("dulwich模块未安装,请查看 https://github.com/RockChinQ/QChatGPT/issues/77")
|
||||
Reference in New Issue
Block a user