AstrBot 4.5.1__py3-none-any.whl → 4.5.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- astrbot/api/__init__.py +10 -11
- astrbot/api/event/__init__.py +5 -6
- astrbot/api/event/filter/__init__.py +37 -36
- astrbot/api/platform/__init__.py +7 -8
- astrbot/api/provider/__init__.py +7 -7
- astrbot/api/star/__init__.py +3 -4
- astrbot/api/util/__init__.py +2 -2
- astrbot/cli/__main__.py +5 -5
- astrbot/cli/commands/__init__.py +3 -3
- astrbot/cli/commands/cmd_conf.py +19 -16
- astrbot/cli/commands/cmd_init.py +3 -2
- astrbot/cli/commands/cmd_plug.py +8 -10
- astrbot/cli/commands/cmd_run.py +5 -6
- astrbot/cli/utils/__init__.py +6 -6
- astrbot/cli/utils/basic.py +14 -14
- astrbot/cli/utils/plugin.py +24 -15
- astrbot/cli/utils/version_comparator.py +10 -12
- astrbot/core/__init__.py +8 -6
- astrbot/core/agent/agent.py +3 -2
- astrbot/core/agent/handoff.py +6 -2
- astrbot/core/agent/hooks.py +9 -6
- astrbot/core/agent/mcp_client.py +50 -15
- astrbot/core/agent/message.py +168 -0
- astrbot/core/agent/response.py +2 -1
- astrbot/core/agent/run_context.py +2 -3
- astrbot/core/agent/runners/base.py +10 -13
- astrbot/core/agent/runners/tool_loop_agent_runner.py +52 -51
- astrbot/core/agent/tool.py +60 -41
- astrbot/core/agent/tool_executor.py +9 -3
- astrbot/core/astr_agent_context.py +3 -1
- astrbot/core/astrbot_config_mgr.py +29 -9
- astrbot/core/config/__init__.py +2 -2
- astrbot/core/config/astrbot_config.py +28 -26
- astrbot/core/config/default.py +4 -6
- astrbot/core/conversation_mgr.py +105 -36
- astrbot/core/core_lifecycle.py +68 -54
- astrbot/core/db/__init__.py +33 -18
- astrbot/core/db/migration/helper.py +12 -10
- astrbot/core/db/migration/migra_3_to_4.py +53 -34
- astrbot/core/db/migration/migra_45_to_46.py +1 -1
- astrbot/core/db/migration/shared_preferences_v3.py +2 -1
- astrbot/core/db/migration/sqlite_v3.py +26 -23
- astrbot/core/db/po.py +27 -18
- astrbot/core/db/sqlite.py +74 -45
- astrbot/core/db/vec_db/base.py +10 -14
- astrbot/core/db/vec_db/faiss_impl/document_storage.py +90 -77
- astrbot/core/db/vec_db/faiss_impl/embedding_storage.py +9 -3
- astrbot/core/db/vec_db/faiss_impl/vec_db.py +36 -31
- astrbot/core/event_bus.py +8 -6
- astrbot/core/file_token_service.py +6 -5
- astrbot/core/initial_loader.py +7 -5
- astrbot/core/knowledge_base/chunking/__init__.py +1 -3
- astrbot/core/knowledge_base/chunking/base.py +1 -0
- astrbot/core/knowledge_base/chunking/fixed_size.py +2 -0
- astrbot/core/knowledge_base/chunking/recursive.py +16 -10
- astrbot/core/knowledge_base/kb_db_sqlite.py +50 -48
- astrbot/core/knowledge_base/kb_helper.py +30 -17
- astrbot/core/knowledge_base/kb_mgr.py +6 -7
- astrbot/core/knowledge_base/models.py +10 -4
- astrbot/core/knowledge_base/parsers/__init__.py +3 -5
- astrbot/core/knowledge_base/parsers/base.py +1 -0
- astrbot/core/knowledge_base/parsers/markitdown_parser.py +2 -1
- astrbot/core/knowledge_base/parsers/pdf_parser.py +2 -1
- astrbot/core/knowledge_base/parsers/text_parser.py +1 -0
- astrbot/core/knowledge_base/parsers/util.py +1 -1
- astrbot/core/knowledge_base/retrieval/__init__.py +6 -8
- astrbot/core/knowledge_base/retrieval/manager.py +17 -14
- astrbot/core/knowledge_base/retrieval/rank_fusion.py +7 -3
- astrbot/core/knowledge_base/retrieval/sparse_retriever.py +11 -5
- astrbot/core/log.py +21 -13
- astrbot/core/message/components.py +123 -217
- astrbot/core/message/message_event_result.py +24 -24
- astrbot/core/persona_mgr.py +20 -11
- astrbot/core/pipeline/__init__.py +7 -7
- astrbot/core/pipeline/content_safety_check/stage.py +13 -9
- astrbot/core/pipeline/content_safety_check/strategies/__init__.py +1 -2
- astrbot/core/pipeline/content_safety_check/strategies/baidu_aip.py +12 -13
- astrbot/core/pipeline/content_safety_check/strategies/keywords.py +1 -0
- astrbot/core/pipeline/content_safety_check/strategies/strategy.py +6 -6
- astrbot/core/pipeline/context.py +4 -1
- astrbot/core/pipeline/context_utils.py +77 -7
- astrbot/core/pipeline/preprocess_stage/stage.py +12 -9
- astrbot/core/pipeline/process_stage/method/llm_request.py +125 -72
- astrbot/core/pipeline/process_stage/method/star_request.py +19 -17
- astrbot/core/pipeline/process_stage/stage.py +13 -10
- astrbot/core/pipeline/process_stage/utils.py +6 -5
- astrbot/core/pipeline/rate_limit_check/stage.py +37 -36
- astrbot/core/pipeline/respond/stage.py +23 -20
- astrbot/core/pipeline/result_decorate/stage.py +31 -23
- astrbot/core/pipeline/scheduler.py +12 -8
- astrbot/core/pipeline/session_status_check/stage.py +12 -8
- astrbot/core/pipeline/stage.py +10 -4
- astrbot/core/pipeline/waking_check/stage.py +24 -18
- astrbot/core/pipeline/whitelist_check/stage.py +10 -7
- astrbot/core/platform/__init__.py +6 -6
- astrbot/core/platform/astr_message_event.py +76 -110
- astrbot/core/platform/astrbot_message.py +11 -13
- astrbot/core/platform/manager.py +16 -15
- astrbot/core/platform/message_session.py +5 -3
- astrbot/core/platform/platform.py +16 -24
- astrbot/core/platform/platform_metadata.py +4 -4
- astrbot/core/platform/register.py +8 -8
- astrbot/core/platform/sources/aiocqhttp/aiocqhttp_message_event.py +23 -15
- astrbot/core/platform/sources/aiocqhttp/aiocqhttp_platform_adapter.py +51 -33
- astrbot/core/platform/sources/dingtalk/dingtalk_adapter.py +42 -27
- astrbot/core/platform/sources/dingtalk/dingtalk_event.py +7 -3
- astrbot/core/platform/sources/discord/client.py +9 -6
- astrbot/core/platform/sources/discord/components.py +18 -14
- astrbot/core/platform/sources/discord/discord_platform_adapter.py +45 -30
- astrbot/core/platform/sources/discord/discord_platform_event.py +38 -30
- astrbot/core/platform/sources/lark/lark_adapter.py +23 -17
- astrbot/core/platform/sources/lark/lark_event.py +21 -14
- astrbot/core/platform/sources/misskey/misskey_adapter.py +107 -67
- astrbot/core/platform/sources/misskey/misskey_api.py +153 -129
- astrbot/core/platform/sources/misskey/misskey_event.py +20 -15
- astrbot/core/platform/sources/misskey/misskey_utils.py +74 -62
- astrbot/core/platform/sources/qqofficial/qqofficial_message_event.py +63 -44
- astrbot/core/platform/sources/qqofficial/qqofficial_platform_adapter.py +41 -26
- astrbot/core/platform/sources/qqofficial_webhook/qo_webhook_adapter.py +36 -17
- astrbot/core/platform/sources/qqofficial_webhook/qo_webhook_event.py +3 -1
- astrbot/core/platform/sources/qqofficial_webhook/qo_webhook_server.py +12 -7
- astrbot/core/platform/sources/satori/satori_adapter.py +56 -38
- astrbot/core/platform/sources/satori/satori_event.py +34 -25
- astrbot/core/platform/sources/slack/client.py +11 -9
- astrbot/core/platform/sources/slack/slack_adapter.py +52 -36
- astrbot/core/platform/sources/slack/slack_event.py +34 -24
- astrbot/core/platform/sources/telegram/tg_adapter.py +38 -18
- astrbot/core/platform/sources/telegram/tg_event.py +32 -18
- astrbot/core/platform/sources/webchat/webchat_adapter.py +27 -17
- astrbot/core/platform/sources/webchat/webchat_event.py +14 -10
- astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py +115 -120
- astrbot/core/platform/sources/wechatpadpro/wechatpadpro_message_event.py +9 -8
- astrbot/core/platform/sources/wechatpadpro/xml_data_parser.py +15 -16
- astrbot/core/platform/sources/wecom/wecom_adapter.py +35 -18
- astrbot/core/platform/sources/wecom/wecom_event.py +55 -48
- astrbot/core/platform/sources/wecom/wecom_kf.py +34 -44
- astrbot/core/platform/sources/wecom/wecom_kf_message.py +26 -10
- astrbot/core/platform/sources/wecom_ai_bot/WXBizJsonMsgCrypt.py +18 -10
- astrbot/core/platform/sources/wecom_ai_bot/__init__.py +3 -5
- astrbot/core/platform/sources/wecom_ai_bot/ierror.py +0 -1
- astrbot/core/platform/sources/wecom_ai_bot/wecomai_adapter.py +61 -37
- astrbot/core/platform/sources/wecom_ai_bot/wecomai_api.py +67 -28
- astrbot/core/platform/sources/wecom_ai_bot/wecomai_event.py +8 -9
- astrbot/core/platform/sources/wecom_ai_bot/wecomai_queue_mgr.py +18 -9
- astrbot/core/platform/sources/wecom_ai_bot/wecomai_server.py +14 -12
- astrbot/core/platform/sources/wecom_ai_bot/wecomai_utils.py +22 -12
- astrbot/core/platform/sources/weixin_official_account/weixin_offacc_adapter.py +40 -26
- astrbot/core/platform/sources/weixin_official_account/weixin_offacc_event.py +47 -45
- astrbot/core/platform_message_history_mgr.py +5 -3
- astrbot/core/provider/__init__.py +2 -3
- astrbot/core/provider/entites.py +8 -8
- astrbot/core/provider/entities.py +61 -75
- astrbot/core/provider/func_tool_manager.py +59 -55
- astrbot/core/provider/manager.py +32 -22
- astrbot/core/provider/provider.py +72 -46
- astrbot/core/provider/register.py +7 -7
- astrbot/core/provider/sources/anthropic_source.py +48 -30
- astrbot/core/provider/sources/azure_tts_source.py +17 -13
- astrbot/core/provider/sources/coze_api_client.py +27 -17
- astrbot/core/provider/sources/coze_source.py +104 -87
- astrbot/core/provider/sources/dashscope_source.py +18 -11
- astrbot/core/provider/sources/dashscope_tts.py +36 -23
- astrbot/core/provider/sources/dify_source.py +25 -20
- astrbot/core/provider/sources/edge_tts_source.py +21 -17
- astrbot/core/provider/sources/fishaudio_tts_api_source.py +22 -14
- astrbot/core/provider/sources/gemini_embedding_source.py +12 -13
- astrbot/core/provider/sources/gemini_source.py +72 -58
- astrbot/core/provider/sources/gemini_tts_source.py +8 -6
- astrbot/core/provider/sources/gsv_selfhosted_source.py +17 -14
- astrbot/core/provider/sources/gsvi_tts_source.py +11 -7
- astrbot/core/provider/sources/minimax_tts_api_source.py +50 -40
- astrbot/core/provider/sources/openai_embedding_source.py +6 -8
- astrbot/core/provider/sources/openai_source.py +77 -69
- astrbot/core/provider/sources/openai_tts_api_source.py +14 -6
- astrbot/core/provider/sources/sensevoice_selfhosted_source.py +13 -11
- astrbot/core/provider/sources/vllm_rerank_source.py +10 -4
- astrbot/core/provider/sources/volcengine_tts.py +38 -31
- astrbot/core/provider/sources/whisper_api_source.py +14 -12
- astrbot/core/provider/sources/whisper_selfhosted_source.py +15 -11
- astrbot/core/provider/sources/xinference_rerank_source.py +16 -8
- astrbot/core/provider/sources/xinference_stt_provider.py +35 -25
- astrbot/core/star/__init__.py +16 -11
- astrbot/core/star/config.py +10 -15
- astrbot/core/star/context.py +97 -75
- astrbot/core/star/filter/__init__.py +4 -3
- astrbot/core/star/filter/command.py +30 -28
- astrbot/core/star/filter/command_group.py +27 -24
- astrbot/core/star/filter/custom_filter.py +6 -5
- astrbot/core/star/filter/event_message_type.py +4 -2
- astrbot/core/star/filter/permission.py +4 -2
- astrbot/core/star/filter/platform_adapter_type.py +4 -2
- astrbot/core/star/filter/regex.py +4 -2
- astrbot/core/star/register/__init__.py +19 -19
- astrbot/core/star/register/star.py +6 -2
- astrbot/core/star/register/star_handler.py +96 -73
- astrbot/core/star/session_llm_manager.py +48 -14
- astrbot/core/star/session_plugin_manager.py +29 -15
- astrbot/core/star/star.py +1 -2
- astrbot/core/star/star_handler.py +13 -8
- astrbot/core/star/star_manager.py +151 -59
- astrbot/core/star/star_tools.py +44 -37
- astrbot/core/star/updator.py +10 -10
- astrbot/core/umop_config_router.py +10 -4
- astrbot/core/updator.py +13 -5
- astrbot/core/utils/astrbot_path.py +3 -5
- astrbot/core/utils/dify_api_client.py +33 -15
- astrbot/core/utils/io.py +66 -42
- astrbot/core/utils/log_pipe.py +1 -1
- astrbot/core/utils/metrics.py +7 -7
- astrbot/core/utils/path_util.py +15 -16
- astrbot/core/utils/pip_installer.py +5 -5
- astrbot/core/utils/session_waiter.py +19 -20
- astrbot/core/utils/shared_preferences.py +45 -20
- astrbot/core/utils/t2i/__init__.py +4 -1
- astrbot/core/utils/t2i/network_strategy.py +35 -26
- astrbot/core/utils/t2i/renderer.py +11 -5
- astrbot/core/utils/t2i/template_manager.py +14 -15
- astrbot/core/utils/tencent_record_helper.py +19 -13
- astrbot/core/utils/version_comparator.py +10 -13
- astrbot/core/zip_updator.py +43 -40
- astrbot/dashboard/routes/__init__.py +18 -18
- astrbot/dashboard/routes/auth.py +10 -8
- astrbot/dashboard/routes/chat.py +30 -21
- astrbot/dashboard/routes/config.py +92 -75
- astrbot/dashboard/routes/conversation.py +46 -39
- astrbot/dashboard/routes/file.py +4 -2
- astrbot/dashboard/routes/knowledge_base.py +47 -40
- astrbot/dashboard/routes/log.py +9 -4
- astrbot/dashboard/routes/persona.py +19 -16
- astrbot/dashboard/routes/plugin.py +69 -55
- astrbot/dashboard/routes/route.py +3 -1
- astrbot/dashboard/routes/session_management.py +130 -116
- astrbot/dashboard/routes/stat.py +34 -34
- astrbot/dashboard/routes/t2i.py +15 -12
- astrbot/dashboard/routes/tools.py +56 -53
- astrbot/dashboard/routes/update.py +32 -28
- astrbot/dashboard/server.py +30 -26
- astrbot/dashboard/utils.py +8 -4
- {astrbot-4.5.1.dist-info → astrbot-4.5.3.dist-info}/METADATA +2 -1
- astrbot-4.5.3.dist-info/RECORD +261 -0
- astrbot-4.5.1.dist-info/RECORD +0 -260
- {astrbot-4.5.1.dist-info → astrbot-4.5.3.dist-info}/WHEEL +0 -0
- {astrbot-4.5.1.dist-info → astrbot-4.5.3.dist-info}/entry_points.txt +0 -0
- {astrbot-4.5.1.dist-info → astrbot-4.5.3.dist-info}/licenses/LICENSE +0 -0
astrbot/api/__init__.py
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
from astrbot.core.config.astrbot_config import AstrBotConfig
|
|
2
1
|
from astrbot import logger
|
|
3
|
-
from astrbot.core import html_renderer
|
|
4
|
-
from astrbot.core import
|
|
5
|
-
from astrbot.core.star.register import register_llm_tool as llm_tool
|
|
6
|
-
from astrbot.core.star.register import register_agent as agent
|
|
7
|
-
from astrbot.core.agent.tool import ToolSet, FunctionTool
|
|
2
|
+
from astrbot.core import html_renderer, sp
|
|
3
|
+
from astrbot.core.agent.tool import FunctionTool, ToolSet
|
|
8
4
|
from astrbot.core.agent.tool_executor import BaseFunctionToolExecutor
|
|
5
|
+
from astrbot.core.config.astrbot_config import AstrBotConfig
|
|
6
|
+
from astrbot.core.star.register import register_agent as agent
|
|
7
|
+
from astrbot.core.star.register import register_llm_tool as llm_tool
|
|
9
8
|
|
|
10
9
|
__all__ = [
|
|
11
10
|
"AstrBotConfig",
|
|
12
|
-
"
|
|
11
|
+
"BaseFunctionToolExecutor",
|
|
12
|
+
"FunctionTool",
|
|
13
|
+
"ToolSet",
|
|
14
|
+
"agent",
|
|
13
15
|
"html_renderer",
|
|
14
16
|
"llm_tool",
|
|
15
|
-
"
|
|
17
|
+
"logger",
|
|
16
18
|
"sp",
|
|
17
|
-
"ToolSet",
|
|
18
|
-
"FunctionTool",
|
|
19
|
-
"BaseFunctionToolExecutor",
|
|
20
19
|
]
|
astrbot/api/event/__init__.py
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
from astrbot.core.message.message_event_result import (
|
|
2
|
-
MessageEventResult,
|
|
3
|
-
MessageChain,
|
|
4
2
|
CommandResult,
|
|
5
3
|
EventResultType,
|
|
4
|
+
MessageChain,
|
|
5
|
+
MessageEventResult,
|
|
6
6
|
ResultContentType,
|
|
7
7
|
)
|
|
8
|
-
|
|
9
8
|
from astrbot.core.platform import AstrMessageEvent
|
|
10
9
|
|
|
11
10
|
__all__ = [
|
|
12
|
-
"
|
|
13
|
-
"MessageChain",
|
|
11
|
+
"AstrMessageEvent",
|
|
14
12
|
"CommandResult",
|
|
15
13
|
"EventResultType",
|
|
16
|
-
"
|
|
14
|
+
"MessageChain",
|
|
15
|
+
"MessageEventResult",
|
|
17
16
|
"ResultContentType",
|
|
18
17
|
]
|
|
@@ -1,51 +1,52 @@
|
|
|
1
|
-
from astrbot.core.star.
|
|
2
|
-
register_command as command,
|
|
3
|
-
register_command_group as command_group,
|
|
4
|
-
register_event_message_type as event_message_type,
|
|
5
|
-
register_regex as regex,
|
|
6
|
-
register_platform_adapter_type as platform_adapter_type,
|
|
7
|
-
register_permission_type as permission_type,
|
|
8
|
-
register_custom_filter as custom_filter,
|
|
9
|
-
register_on_astrbot_loaded as on_astrbot_loaded,
|
|
10
|
-
register_on_platform_loaded as on_platform_loaded,
|
|
11
|
-
register_on_llm_request as on_llm_request,
|
|
12
|
-
register_on_llm_response as on_llm_response,
|
|
13
|
-
register_llm_tool as llm_tool,
|
|
14
|
-
register_on_decorating_result as on_decorating_result,
|
|
15
|
-
register_after_message_sent as after_message_sent,
|
|
16
|
-
)
|
|
17
|
-
|
|
1
|
+
from astrbot.core.star.filter.custom_filter import CustomFilter
|
|
18
2
|
from astrbot.core.star.filter.event_message_type import (
|
|
19
|
-
EventMessageTypeFilter,
|
|
20
3
|
EventMessageType,
|
|
4
|
+
EventMessageTypeFilter,
|
|
21
5
|
)
|
|
6
|
+
from astrbot.core.star.filter.permission import PermissionType, PermissionTypeFilter
|
|
22
7
|
from astrbot.core.star.filter.platform_adapter_type import (
|
|
23
|
-
PlatformAdapterTypeFilter,
|
|
24
8
|
PlatformAdapterType,
|
|
9
|
+
PlatformAdapterTypeFilter,
|
|
25
10
|
)
|
|
26
|
-
from astrbot.core.star.
|
|
27
|
-
from astrbot.core.star.
|
|
11
|
+
from astrbot.core.star.register import register_after_message_sent as after_message_sent
|
|
12
|
+
from astrbot.core.star.register import register_command as command
|
|
13
|
+
from astrbot.core.star.register import register_command_group as command_group
|
|
14
|
+
from astrbot.core.star.register import register_custom_filter as custom_filter
|
|
15
|
+
from astrbot.core.star.register import register_event_message_type as event_message_type
|
|
16
|
+
from astrbot.core.star.register import register_llm_tool as llm_tool
|
|
17
|
+
from astrbot.core.star.register import register_on_astrbot_loaded as on_astrbot_loaded
|
|
18
|
+
from astrbot.core.star.register import (
|
|
19
|
+
register_on_decorating_result as on_decorating_result,
|
|
20
|
+
)
|
|
21
|
+
from astrbot.core.star.register import register_on_llm_request as on_llm_request
|
|
22
|
+
from astrbot.core.star.register import register_on_llm_response as on_llm_response
|
|
23
|
+
from astrbot.core.star.register import register_on_platform_loaded as on_platform_loaded
|
|
24
|
+
from astrbot.core.star.register import register_permission_type as permission_type
|
|
25
|
+
from astrbot.core.star.register import (
|
|
26
|
+
register_platform_adapter_type as platform_adapter_type,
|
|
27
|
+
)
|
|
28
|
+
from astrbot.core.star.register import register_regex as regex
|
|
28
29
|
|
|
29
30
|
__all__ = [
|
|
30
|
-
"
|
|
31
|
-
"command_group",
|
|
32
|
-
"event_message_type",
|
|
33
|
-
"regex",
|
|
34
|
-
"platform_adapter_type",
|
|
35
|
-
"permission_type",
|
|
36
|
-
"EventMessageTypeFilter",
|
|
31
|
+
"CustomFilter",
|
|
37
32
|
"EventMessageType",
|
|
38
|
-
"
|
|
39
|
-
"
|
|
33
|
+
"EventMessageTypeFilter",
|
|
34
|
+
"PermissionType",
|
|
40
35
|
"PermissionTypeFilter",
|
|
41
|
-
"
|
|
36
|
+
"PlatformAdapterType",
|
|
37
|
+
"PlatformAdapterTypeFilter",
|
|
38
|
+
"after_message_sent",
|
|
39
|
+
"command",
|
|
40
|
+
"command_group",
|
|
42
41
|
"custom_filter",
|
|
43
|
-
"
|
|
44
|
-
"on_astrbot_loaded",
|
|
45
|
-
"on_platform_loaded",
|
|
46
|
-
"on_llm_request",
|
|
42
|
+
"event_message_type",
|
|
47
43
|
"llm_tool",
|
|
44
|
+
"on_astrbot_loaded",
|
|
48
45
|
"on_decorating_result",
|
|
49
|
-
"
|
|
46
|
+
"on_llm_request",
|
|
50
47
|
"on_llm_response",
|
|
48
|
+
"on_platform_loaded",
|
|
49
|
+
"permission_type",
|
|
50
|
+
"platform_adapter_type",
|
|
51
|
+
"regex",
|
|
51
52
|
]
|
astrbot/api/platform/__init__.py
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
|
+
from astrbot.core.message.components import *
|
|
1
2
|
from astrbot.core.platform import (
|
|
2
|
-
AstrMessageEvent,
|
|
3
|
-
Platform,
|
|
4
3
|
AstrBotMessage,
|
|
4
|
+
AstrMessageEvent,
|
|
5
|
+
Group,
|
|
5
6
|
MessageMember,
|
|
6
7
|
MessageType,
|
|
8
|
+
Platform,
|
|
7
9
|
PlatformMetadata,
|
|
8
|
-
Group,
|
|
9
10
|
)
|
|
10
|
-
|
|
11
11
|
from astrbot.core.platform.register import register_platform_adapter
|
|
12
|
-
from astrbot.core.message.components import *
|
|
13
12
|
|
|
14
13
|
__all__ = [
|
|
15
|
-
"AstrMessageEvent",
|
|
16
|
-
"Platform",
|
|
17
14
|
"AstrBotMessage",
|
|
15
|
+
"AstrMessageEvent",
|
|
16
|
+
"Group",
|
|
18
17
|
"MessageMember",
|
|
19
18
|
"MessageType",
|
|
19
|
+
"Platform",
|
|
20
20
|
"PlatformMetadata",
|
|
21
21
|
"register_platform_adapter",
|
|
22
|
-
"Group",
|
|
23
22
|
]
|
astrbot/api/provider/__init__.py
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
from astrbot.core.provider import Provider, STTProvider
|
|
1
|
+
from astrbot.core.provider import Personality, Provider, STTProvider
|
|
2
2
|
from astrbot.core.provider.entities import (
|
|
3
|
+
LLMResponse,
|
|
4
|
+
ProviderMetaData,
|
|
3
5
|
ProviderRequest,
|
|
4
6
|
ProviderType,
|
|
5
|
-
ProviderMetaData,
|
|
6
|
-
LLMResponse,
|
|
7
7
|
)
|
|
8
8
|
|
|
9
9
|
__all__ = [
|
|
10
|
-
"
|
|
11
|
-
"STTProvider",
|
|
10
|
+
"LLMResponse",
|
|
12
11
|
"Personality",
|
|
12
|
+
"Provider",
|
|
13
|
+
"ProviderMetaData",
|
|
13
14
|
"ProviderRequest",
|
|
14
15
|
"ProviderType",
|
|
15
|
-
"
|
|
16
|
-
"LLMResponse",
|
|
16
|
+
"STTProvider",
|
|
17
17
|
]
|
astrbot/api/star/__init__.py
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
from astrbot.core.star import Context, Star, StarTools
|
|
2
|
+
from astrbot.core.star.config import *
|
|
1
3
|
from astrbot.core.star.register import (
|
|
2
4
|
register_star as register, # 注册插件(Star)
|
|
3
5
|
)
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
from astrbot.core.star.config import *
|
|
7
|
-
|
|
8
|
-
__all__ = ["register", "Context", "Star", "StarTools"]
|
|
7
|
+
__all__ = ["Context", "Star", "StarTools", "register"]
|
astrbot/api/util/__init__.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from astrbot.core.utils.session_waiter import (
|
|
2
|
-
SessionWaiter,
|
|
3
2
|
SessionController,
|
|
3
|
+
SessionWaiter,
|
|
4
4
|
session_waiter,
|
|
5
5
|
)
|
|
6
6
|
|
|
7
|
-
__all__ = ["
|
|
7
|
+
__all__ = ["SessionController", "SessionWaiter", "session_waiter"]
|
astrbot/cli/__main__.py
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"""
|
|
2
|
-
AstrBot CLI入口
|
|
3
|
-
"""
|
|
1
|
+
"""AstrBot CLI入口"""
|
|
4
2
|
|
|
5
|
-
import click
|
|
6
3
|
import sys
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
|
|
7
7
|
from . import __version__
|
|
8
|
-
from .commands import
|
|
8
|
+
from .commands import conf, init, plug, run
|
|
9
9
|
|
|
10
10
|
logo_tmpl = r"""
|
|
11
11
|
___ _______.___________..______ .______ ______ .___________.
|
astrbot/cli/commands/__init__.py
CHANGED
astrbot/cli/commands/cmd_conf.py
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import json
|
|
2
|
-
import click
|
|
3
1
|
import hashlib
|
|
2
|
+
import json
|
|
4
3
|
import zoneinfo
|
|
5
|
-
from
|
|
6
|
-
from
|
|
4
|
+
from collections.abc import Callable
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
import click
|
|
8
|
+
|
|
9
|
+
from ..utils import check_astrbot_root, get_astrbot_root
|
|
7
10
|
|
|
8
11
|
|
|
9
12
|
def _validate_log_level(value: str) -> str:
|
|
@@ -11,7 +14,7 @@ def _validate_log_level(value: str) -> str:
|
|
|
11
14
|
value = value.upper()
|
|
12
15
|
if value not in ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]:
|
|
13
16
|
raise click.ClickException(
|
|
14
|
-
"日志级别必须是 DEBUG/INFO/WARNING/ERROR/CRITICAL 之一"
|
|
17
|
+
"日志级别必须是 DEBUG/INFO/WARNING/ERROR/CRITICAL 之一",
|
|
15
18
|
)
|
|
16
19
|
return value
|
|
17
20
|
|
|
@@ -73,7 +76,7 @@ def _load_config() -> dict[str, Any]:
|
|
|
73
76
|
root = get_astrbot_root()
|
|
74
77
|
if not check_astrbot_root(root):
|
|
75
78
|
raise click.ClickException(
|
|
76
|
-
f"{root}不是有效的 AstrBot 根目录,如需初始化请使用 astrbot init"
|
|
79
|
+
f"{root}不是有效的 AstrBot 根目录,如需初始化请使用 astrbot init",
|
|
77
80
|
)
|
|
78
81
|
|
|
79
82
|
config_path = root / "data" / "cmd_config.json"
|
|
@@ -88,7 +91,7 @@ def _load_config() -> dict[str, Any]:
|
|
|
88
91
|
try:
|
|
89
92
|
return json.loads(config_path.read_text(encoding="utf-8-sig"))
|
|
90
93
|
except json.JSONDecodeError as e:
|
|
91
|
-
raise click.ClickException(f"配置文件解析失败: {
|
|
94
|
+
raise click.ClickException(f"配置文件解析失败: {e!s}")
|
|
92
95
|
|
|
93
96
|
|
|
94
97
|
def _save_config(config: dict[str, Any]) -> None:
|
|
@@ -96,7 +99,8 @@ def _save_config(config: dict[str, Any]) -> None:
|
|
|
96
99
|
config_path = get_astrbot_root() / "data" / "cmd_config.json"
|
|
97
100
|
|
|
98
101
|
config_path.write_text(
|
|
99
|
-
json.dumps(config, ensure_ascii=False, indent=2),
|
|
102
|
+
json.dumps(config, ensure_ascii=False, indent=2),
|
|
103
|
+
encoding="utf-8-sig",
|
|
100
104
|
)
|
|
101
105
|
|
|
102
106
|
|
|
@@ -108,7 +112,7 @@ def _set_nested_item(obj: dict[str, Any], path: str, value: Any) -> None:
|
|
|
108
112
|
obj[part] = {}
|
|
109
113
|
elif not isinstance(obj[part], dict):
|
|
110
114
|
raise click.ClickException(
|
|
111
|
-
f"配置路径冲突: {'.'.join(parts[: parts.index(part) + 1])} 不是字典"
|
|
115
|
+
f"配置路径冲突: {'.'.join(parts[: parts.index(part) + 1])} 不是字典",
|
|
112
116
|
)
|
|
113
117
|
obj = obj[part]
|
|
114
118
|
obj[parts[-1]] = value
|
|
@@ -140,7 +144,6 @@ def conf():
|
|
|
140
144
|
|
|
141
145
|
- callback_api_base: 回调接口基址
|
|
142
146
|
"""
|
|
143
|
-
pass
|
|
144
147
|
|
|
145
148
|
|
|
146
149
|
@conf.command(name="set")
|
|
@@ -148,7 +151,7 @@ def conf():
|
|
|
148
151
|
@click.argument("value")
|
|
149
152
|
def set_config(key: str, value: str):
|
|
150
153
|
"""设置配置项的值"""
|
|
151
|
-
if key not in CONFIG_VALIDATORS
|
|
154
|
+
if key not in CONFIG_VALIDATORS:
|
|
152
155
|
raise click.ClickException(f"不支持的配置项: {key}")
|
|
153
156
|
|
|
154
157
|
config = _load_config()
|
|
@@ -170,17 +173,17 @@ def set_config(key: str, value: str):
|
|
|
170
173
|
except KeyError:
|
|
171
174
|
raise click.ClickException(f"未知的配置项: {key}")
|
|
172
175
|
except Exception as e:
|
|
173
|
-
raise click.UsageError(f"设置配置失败: {
|
|
176
|
+
raise click.UsageError(f"设置配置失败: {e!s}")
|
|
174
177
|
|
|
175
178
|
|
|
176
179
|
@conf.command(name="get")
|
|
177
180
|
@click.argument("key", required=False)
|
|
178
|
-
def get_config(key: str = None):
|
|
181
|
+
def get_config(key: str | None = None):
|
|
179
182
|
"""获取配置项的值,不提供key则显示所有可配置项"""
|
|
180
183
|
config = _load_config()
|
|
181
184
|
|
|
182
185
|
if key:
|
|
183
|
-
if key not in CONFIG_VALIDATORS
|
|
186
|
+
if key not in CONFIG_VALIDATORS:
|
|
184
187
|
raise click.ClickException(f"不支持的配置项: {key}")
|
|
185
188
|
|
|
186
189
|
try:
|
|
@@ -191,10 +194,10 @@ def get_config(key: str = None):
|
|
|
191
194
|
except KeyError:
|
|
192
195
|
raise click.ClickException(f"未知的配置项: {key}")
|
|
193
196
|
except Exception as e:
|
|
194
|
-
raise click.UsageError(f"获取配置失败: {
|
|
197
|
+
raise click.UsageError(f"获取配置失败: {e!s}")
|
|
195
198
|
else:
|
|
196
199
|
click.echo("当前配置:")
|
|
197
|
-
for key in CONFIG_VALIDATORS
|
|
200
|
+
for key in CONFIG_VALIDATORS:
|
|
198
201
|
try:
|
|
199
202
|
value = (
|
|
200
203
|
"********"
|
astrbot/cli/commands/cmd_init.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import asyncio
|
|
2
|
+
from pathlib import Path
|
|
2
3
|
|
|
3
4
|
import click
|
|
4
5
|
from filelock import FileLock, Timeout
|
|
@@ -6,14 +7,14 @@ from filelock import FileLock, Timeout
|
|
|
6
7
|
from ..utils import check_dashboard, get_astrbot_root
|
|
7
8
|
|
|
8
9
|
|
|
9
|
-
async def initialize_astrbot(astrbot_root) -> None:
|
|
10
|
+
async def initialize_astrbot(astrbot_root: Path) -> None:
|
|
10
11
|
"""执行 AstrBot 初始化逻辑"""
|
|
11
12
|
dot_astrbot = astrbot_root / ".astrbot"
|
|
12
13
|
|
|
13
14
|
if not dot_astrbot.exists():
|
|
14
15
|
click.echo(f"Current Directory: {astrbot_root}")
|
|
15
16
|
click.echo(
|
|
16
|
-
"如果你确认这是 Astrbot root directory, 你需要在当前目录下创建一个 .astrbot 文件标记该目录为 AstrBot 的数据目录。"
|
|
17
|
+
"如果你确认这是 Astrbot root directory, 你需要在当前目录下创建一个 .astrbot 文件标记该目录为 AstrBot 的数据目录。",
|
|
17
18
|
)
|
|
18
19
|
if click.confirm(
|
|
19
20
|
f"请检查当前目录是否正确,确认正确请回车: {astrbot_root}",
|
astrbot/cli/commands/cmd_plug.py
CHANGED
|
@@ -1,31 +1,29 @@
|
|
|
1
1
|
import re
|
|
2
|
+
import shutil
|
|
2
3
|
from pathlib import Path
|
|
3
4
|
|
|
4
5
|
import click
|
|
5
|
-
import shutil
|
|
6
|
-
|
|
7
6
|
|
|
8
7
|
from ..utils import (
|
|
9
|
-
get_git_repo,
|
|
10
|
-
build_plug_list,
|
|
11
|
-
manage_plugin,
|
|
12
8
|
PluginStatus,
|
|
9
|
+
build_plug_list,
|
|
13
10
|
check_astrbot_root,
|
|
14
11
|
get_astrbot_root,
|
|
12
|
+
get_git_repo,
|
|
13
|
+
manage_plugin,
|
|
15
14
|
)
|
|
16
15
|
|
|
17
16
|
|
|
18
17
|
@click.group()
|
|
19
18
|
def plug():
|
|
20
19
|
"""插件管理"""
|
|
21
|
-
pass
|
|
22
20
|
|
|
23
21
|
|
|
24
22
|
def _get_data_path() -> Path:
|
|
25
23
|
base = get_astrbot_root()
|
|
26
24
|
if not check_astrbot_root(base):
|
|
27
25
|
raise click.ClickException(
|
|
28
|
-
f"{base}不是有效的 AstrBot 根目录,如需初始化请使用 astrbot init"
|
|
26
|
+
f"{base}不是有效的 AstrBot 根目录,如需初始化请使用 astrbot init",
|
|
29
27
|
)
|
|
30
28
|
return (base / "data").resolve()
|
|
31
29
|
|
|
@@ -41,7 +39,7 @@ def display_plugins(plugins, title=None, color=None):
|
|
|
41
39
|
desc = p["desc"][:30] + ("..." if len(p["desc"]) > 30 else "")
|
|
42
40
|
click.echo(
|
|
43
41
|
f"{p['name']:<20} {p['version']:<10} {p['status']:<10} "
|
|
44
|
-
f"{p['author']:<15} {desc:<30}"
|
|
42
|
+
f"{p['author']:<15} {desc:<30}",
|
|
45
43
|
)
|
|
46
44
|
|
|
47
45
|
|
|
@@ -78,7 +76,7 @@ def new(name: str):
|
|
|
78
76
|
f"desc: {desc}\n"
|
|
79
77
|
f"version: {version}\n"
|
|
80
78
|
f"author: {author}\n"
|
|
81
|
-
f"repo: {repo}\n"
|
|
79
|
+
f"repo: {repo}\n",
|
|
82
80
|
)
|
|
83
81
|
|
|
84
82
|
# 重写 README.md
|
|
@@ -86,7 +84,7 @@ def new(name: str):
|
|
|
86
84
|
f.write(f"# {name}\n\n{desc}\n\n# 支持\n\n[帮助文档](https://astrbot.app)\n")
|
|
87
85
|
|
|
88
86
|
# 重写 main.py
|
|
89
|
-
with open(plug_path / "main.py",
|
|
87
|
+
with open(plug_path / "main.py", encoding="utf-8") as f:
|
|
90
88
|
content = f.read()
|
|
91
89
|
|
|
92
90
|
new_content = content.replace(
|
astrbot/cli/commands/cmd_run.py
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
|
+
import asyncio
|
|
1
2
|
import os
|
|
2
3
|
import sys
|
|
4
|
+
import traceback
|
|
3
5
|
from pathlib import Path
|
|
4
6
|
|
|
5
7
|
import click
|
|
6
|
-
import asyncio
|
|
7
|
-
import traceback
|
|
8
|
-
|
|
9
8
|
from filelock import FileLock, Timeout
|
|
10
9
|
|
|
11
|
-
from ..utils import
|
|
10
|
+
from ..utils import check_astrbot_root, check_dashboard, get_astrbot_root
|
|
12
11
|
|
|
13
12
|
|
|
14
13
|
async def run_astrbot(astrbot_root: Path):
|
|
15
14
|
"""运行 AstrBot"""
|
|
16
|
-
from astrbot.core import
|
|
15
|
+
from astrbot.core import LogBroker, LogManager, db_helper, logger
|
|
17
16
|
from astrbot.core.initial_loader import InitialLoader
|
|
18
17
|
|
|
19
18
|
await check_dashboard(astrbot_root / "data")
|
|
@@ -38,7 +37,7 @@ def run(reload: bool, port: str) -> None:
|
|
|
38
37
|
|
|
39
38
|
if not check_astrbot_root(astrbot_root):
|
|
40
39
|
raise click.ClickException(
|
|
41
|
-
f"{astrbot_root}不是有效的 AstrBot 根目录,如需初始化请使用 astrbot init"
|
|
40
|
+
f"{astrbot_root}不是有效的 AstrBot 根目录,如需初始化请使用 astrbot init",
|
|
42
41
|
)
|
|
43
42
|
|
|
44
43
|
os.environ["ASTRBOT_ROOT"] = str(astrbot_root)
|
astrbot/cli/utils/__init__.py
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
from .basic import (
|
|
2
|
-
get_astrbot_root,
|
|
3
2
|
check_astrbot_root,
|
|
4
3
|
check_dashboard,
|
|
4
|
+
get_astrbot_root,
|
|
5
5
|
)
|
|
6
|
-
from .plugin import
|
|
6
|
+
from .plugin import PluginStatus, build_plug_list, get_git_repo, manage_plugin
|
|
7
7
|
from .version_comparator import VersionComparator
|
|
8
8
|
|
|
9
9
|
__all__ = [
|
|
10
|
-
"
|
|
10
|
+
"PluginStatus",
|
|
11
|
+
"VersionComparator",
|
|
12
|
+
"build_plug_list",
|
|
11
13
|
"check_astrbot_root",
|
|
12
14
|
"check_dashboard",
|
|
15
|
+
"get_astrbot_root",
|
|
13
16
|
"get_git_repo",
|
|
14
17
|
"manage_plugin",
|
|
15
|
-
"build_plug_list",
|
|
16
|
-
"VersionComparator",
|
|
17
|
-
"PluginStatus",
|
|
18
18
|
]
|
astrbot/cli/utils/basic.py
CHANGED
|
@@ -21,8 +21,9 @@ def get_astrbot_root() -> Path:
|
|
|
21
21
|
|
|
22
22
|
async def check_dashboard(astrbot_root: Path) -> None:
|
|
23
23
|
"""检查是否安装了dashboard"""
|
|
24
|
-
from astrbot.core.utils.io import get_dashboard_version, download_dashboard
|
|
25
24
|
from astrbot.core.config.default import VERSION
|
|
25
|
+
from astrbot.core.utils.io import download_dashboard, get_dashboard_version
|
|
26
|
+
|
|
26
27
|
from .version_comparator import VersionComparator
|
|
27
28
|
|
|
28
29
|
try:
|
|
@@ -48,19 +49,18 @@ async def check_dashboard(astrbot_root: Path) -> None:
|
|
|
48
49
|
if VersionComparator.compare_version(VERSION, dashboard_version) <= 0:
|
|
49
50
|
click.echo("管理面板已是最新版本")
|
|
50
51
|
return
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return
|
|
52
|
+
try:
|
|
53
|
+
version = dashboard_version.split("v")[1]
|
|
54
|
+
click.echo(f"管理面板版本: {version}")
|
|
55
|
+
await download_dashboard(
|
|
56
|
+
path="data/dashboard.zip",
|
|
57
|
+
extract_path=str(astrbot_root),
|
|
58
|
+
version=f"v{VERSION}",
|
|
59
|
+
latest=False,
|
|
60
|
+
)
|
|
61
|
+
except Exception as e:
|
|
62
|
+
click.echo(f"下载管理面板失败: {e}")
|
|
63
|
+
return
|
|
64
64
|
except FileNotFoundError:
|
|
65
65
|
click.echo("初始化管理面板目录...")
|
|
66
66
|
try:
|