mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-02 03:55:55 +00:00
chore: no longer run config migrations when config files are not exist
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import secrets
|
import secrets
|
||||||
|
import os
|
||||||
|
|
||||||
from .. import stage, app
|
from .. import stage, app
|
||||||
from ..bootutils import config
|
from ..bootutils import config
|
||||||
@@ -19,46 +20,20 @@ class LoadConfigStage(stage.BootingStage):
|
|||||||
ap.settings_mgr = settings_mgr.SettingsManager(ap)
|
ap.settings_mgr = settings_mgr.SettingsManager(ap)
|
||||||
await ap.settings_mgr.initialize()
|
await ap.settings_mgr.initialize()
|
||||||
|
|
||||||
ap.command_cfg = await config.load_json_config("data/config/command.json", "templates/command.json", completion=False)
|
if os.path.exists("data/config/command.json"):
|
||||||
ap.pipeline_cfg = await config.load_json_config("data/config/pipeline.json", "templates/pipeline.json", completion=False)
|
ap.command_cfg = await config.load_json_config("data/config/command.json", "templates/command.json", completion=False)
|
||||||
ap.platform_cfg = await config.load_json_config("data/config/platform.json", "templates/platform.json", completion=False)
|
|
||||||
ap.provider_cfg = await config.load_json_config("data/config/provider.json", "templates/provider.json", completion=False)
|
|
||||||
ap.system_cfg = await config.load_json_config("data/config/system.json", "templates/system.json", completion=False)
|
|
||||||
|
|
||||||
ap.settings_mgr.register_manager(
|
if os.path.exists("data/config/pipeline.json"):
|
||||||
name="command.json",
|
ap.pipeline_cfg = await config.load_json_config("data/config/pipeline.json", "templates/pipeline.json", completion=False)
|
||||||
description="命令配置",
|
|
||||||
manager=ap.command_cfg,
|
|
||||||
doc_link="https://docs.langbot.app/config/function/command.html"
|
|
||||||
)
|
|
||||||
|
|
||||||
ap.settings_mgr.register_manager(
|
if os.path.exists("data/config/platform.json"):
|
||||||
name="pipeline.json",
|
ap.platform_cfg = await config.load_json_config("data/config/platform.json", "templates/platform.json", completion=False)
|
||||||
description="消息处理流水线配置",
|
|
||||||
manager=ap.pipeline_cfg,
|
|
||||||
doc_link="https://docs.langbot.app/config/function/pipeline.html"
|
|
||||||
)
|
|
||||||
|
|
||||||
ap.settings_mgr.register_manager(
|
if os.path.exists("data/config/provider.json"):
|
||||||
name="platform.json",
|
ap.provider_cfg = await config.load_json_config("data/config/provider.json", "templates/provider.json", completion=False)
|
||||||
description="消息平台配置",
|
|
||||||
manager=ap.platform_cfg,
|
|
||||||
doc_link="https://docs.langbot.app/config/function/platform.html"
|
|
||||||
)
|
|
||||||
|
|
||||||
ap.settings_mgr.register_manager(
|
if os.path.exists("data/config/system.json"):
|
||||||
name="provider.json",
|
ap.system_cfg = await config.load_json_config("data/config/system.json", "templates/system.json", completion=False)
|
||||||
description="大模型能力配置",
|
|
||||||
manager=ap.provider_cfg,
|
|
||||||
doc_link="https://docs.langbot.app/config/function/provider.html"
|
|
||||||
)
|
|
||||||
|
|
||||||
ap.settings_mgr.register_manager(
|
|
||||||
name="system.json",
|
|
||||||
description="系统配置",
|
|
||||||
manager=ap.system_cfg,
|
|
||||||
doc_link="https://docs.langbot.app/config/function/system.html"
|
|
||||||
)
|
|
||||||
|
|
||||||
ap.sensitive_meta = await config.load_json_config("data/metadata/sensitive-words.json", "templates/metadata/sensitive-words.json")
|
ap.sensitive_meta = await config.load_json_config("data/metadata/sensitive-words.json", "templates/metadata/sensitive-words.json")
|
||||||
await ap.sensitive_meta.dump_config()
|
await ap.sensitive_meta.dump_config()
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import importlib
|
import importlib
|
||||||
|
import os
|
||||||
|
|
||||||
from .. import stage, app
|
from .. import stage, app
|
||||||
from .. import migration
|
from .. import migration
|
||||||
@@ -24,6 +25,15 @@ class MigrationStage(stage.BootingStage):
|
|||||||
"""启动
|
"""启动
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if any([
|
||||||
|
ap.command_cfg is None,
|
||||||
|
ap.pipeline_cfg is None,
|
||||||
|
ap.platform_cfg is None,
|
||||||
|
ap.provider_cfg is None,
|
||||||
|
ap.system_cfg is None,
|
||||||
|
]): # only run migration when version is 3.x
|
||||||
|
return
|
||||||
|
|
||||||
migrations = migration.preregistered_migrations
|
migrations = migration.preregistered_migrations
|
||||||
|
|
||||||
# 按照迁移号排序
|
# 按照迁移号排序
|
||||||
|
|||||||
Reference in New Issue
Block a user