mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-09 15:26:03 +00:00
feat: 重载后恢复诸个单例对象
This commit is contained in:
31
pkg/utils/context.py
Normal file
31
pkg/utils/context.py
Normal file
@@ -0,0 +1,31 @@
|
||||
context = {
|
||||
'inst': {
|
||||
'database.manager.DatabaseManager': None,
|
||||
'openai.manager.OpenAIInteract': None,
|
||||
'qqbot.manager.QQBotManager': None,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def set_database_manager(inst):
|
||||
context['inst']['database.manager.DatabaseManager'] = inst
|
||||
|
||||
|
||||
def get_database_manager():
|
||||
return context['inst']['database.manager.DatabaseManager']
|
||||
|
||||
|
||||
def set_openai_manager(inst):
|
||||
context['inst']['openai.manager.OpenAIInteract'] = inst
|
||||
|
||||
|
||||
def get_openai_manager():
|
||||
return context['inst']['openai.manager.OpenAIInteract']
|
||||
|
||||
|
||||
def set_qqbot_manager(inst):
|
||||
context['inst']['qqbot.manager.QQBotManager'] = inst
|
||||
|
||||
|
||||
def get_qqbot_manager():
|
||||
return context['inst']['qqbot.manager.QQBotManager']
|
||||
Reference in New Issue
Block a user