AstrBot 4.10.1__py3-none-any.whl → 4.10.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/builtin_stars/astrbot/long_term_memory.py +186 -0
- astrbot/builtin_stars/astrbot/main.py +128 -0
- astrbot/builtin_stars/astrbot/metadata.yaml +4 -0
- astrbot/builtin_stars/astrbot/process_llm_request.py +245 -0
- astrbot/builtin_stars/builtin_commands/commands/__init__.py +31 -0
- astrbot/builtin_stars/builtin_commands/commands/admin.py +77 -0
- astrbot/builtin_stars/builtin_commands/commands/alter_cmd.py +173 -0
- astrbot/builtin_stars/builtin_commands/commands/conversation.py +366 -0
- astrbot/builtin_stars/builtin_commands/commands/help.py +88 -0
- astrbot/builtin_stars/builtin_commands/commands/llm.py +20 -0
- astrbot/builtin_stars/builtin_commands/commands/persona.py +142 -0
- astrbot/builtin_stars/builtin_commands/commands/plugin.py +120 -0
- astrbot/builtin_stars/builtin_commands/commands/provider.py +329 -0
- astrbot/builtin_stars/builtin_commands/commands/setunset.py +36 -0
- astrbot/builtin_stars/builtin_commands/commands/sid.py +36 -0
- astrbot/builtin_stars/builtin_commands/commands/t2i.py +23 -0
- astrbot/builtin_stars/builtin_commands/commands/tool.py +31 -0
- astrbot/builtin_stars/builtin_commands/commands/tts.py +36 -0
- astrbot/builtin_stars/builtin_commands/commands/utils/rst_scene.py +26 -0
- astrbot/builtin_stars/builtin_commands/main.py +237 -0
- astrbot/builtin_stars/builtin_commands/metadata.yaml +4 -0
- astrbot/builtin_stars/python_interpreter/main.py +537 -0
- astrbot/builtin_stars/python_interpreter/metadata.yaml +4 -0
- astrbot/builtin_stars/python_interpreter/requirements.txt +1 -0
- astrbot/builtin_stars/python_interpreter/shared/api.py +22 -0
- astrbot/builtin_stars/reminder/main.py +266 -0
- astrbot/builtin_stars/reminder/metadata.yaml +4 -0
- astrbot/builtin_stars/session_controller/main.py +114 -0
- astrbot/builtin_stars/session_controller/metadata.yaml +5 -0
- astrbot/builtin_stars/web_searcher/engines/__init__.py +111 -0
- astrbot/builtin_stars/web_searcher/engines/bing.py +30 -0
- astrbot/builtin_stars/web_searcher/engines/sogo.py +52 -0
- astrbot/builtin_stars/web_searcher/main.py +436 -0
- astrbot/builtin_stars/web_searcher/metadata.yaml +4 -0
- astrbot/cli/__init__.py +1 -1
- astrbot/core/agent/message.py +9 -0
- astrbot/core/agent/runners/tool_loop_agent_runner.py +2 -1
- astrbot/core/backup/__init__.py +26 -0
- astrbot/core/backup/constants.py +77 -0
- astrbot/core/backup/exporter.py +476 -0
- astrbot/core/backup/importer.py +761 -0
- astrbot/core/config/default.py +1 -1
- astrbot/core/log.py +1 -1
- astrbot/core/pipeline/process_stage/method/agent_sub_stages/internal.py +1 -1
- astrbot/core/pipeline/waking_check/stage.py +2 -1
- astrbot/core/provider/entities.py +32 -9
- astrbot/core/provider/provider.py +3 -1
- astrbot/core/provider/sources/anthropic_source.py +80 -27
- astrbot/core/provider/sources/fishaudio_tts_api_source.py +14 -6
- astrbot/core/provider/sources/gemini_source.py +75 -26
- astrbot/core/provider/sources/openai_source.py +68 -25
- astrbot/core/star/command_management.py +45 -4
- astrbot/core/star/context.py +1 -1
- astrbot/core/star/star_manager.py +11 -13
- astrbot/core/utils/astrbot_path.py +34 -0
- astrbot/dashboard/routes/__init__.py +2 -0
- astrbot/dashboard/routes/backup.py +589 -0
- astrbot/dashboard/routes/command.py +2 -1
- astrbot/dashboard/routes/log.py +44 -10
- astrbot/dashboard/server.py +8 -1
- {astrbot-4.10.1.dist-info → astrbot-4.10.3.dist-info}/METADATA +2 -2
- {astrbot-4.10.1.dist-info → astrbot-4.10.3.dist-info}/RECORD +65 -26
- {astrbot-4.10.1.dist-info → astrbot-4.10.3.dist-info}/WHEEL +0 -0
- {astrbot-4.10.1.dist-info → astrbot-4.10.3.dist-info}/entry_points.txt +0 -0
- {astrbot-4.10.1.dist-info → astrbot-4.10.3.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from astrbot.api import star
|
|
2
|
+
from astrbot.api.event import AstrMessageEvent, MessageEventResult
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class ToolCommands:
|
|
6
|
+
def __init__(self, context: star.Context):
|
|
7
|
+
self.context = context
|
|
8
|
+
|
|
9
|
+
async def tool_ls(self, event: AstrMessageEvent):
|
|
10
|
+
"""查看函数工具列表"""
|
|
11
|
+
event.set_result(
|
|
12
|
+
MessageEventResult().message("tool 指令在 AstrBot v4.0.0 已经被移除。"),
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
async def tool_on(self, event: AstrMessageEvent, tool_name: str = ""):
|
|
16
|
+
"""启用一个函数工具"""
|
|
17
|
+
event.set_result(
|
|
18
|
+
MessageEventResult().message("tool 指令在 AstrBot v4.0.0 已经被移除。"),
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
async def tool_off(self, event: AstrMessageEvent, tool_name: str = ""):
|
|
22
|
+
"""停用一个函数工具"""
|
|
23
|
+
event.set_result(
|
|
24
|
+
MessageEventResult().message("tool 指令在 AstrBot v4.0.0 已经被移除。"),
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
async def tool_all_off(self, event: AstrMessageEvent):
|
|
28
|
+
"""停用所有函数工具"""
|
|
29
|
+
event.set_result(
|
|
30
|
+
MessageEventResult().message("tool 指令在 AstrBot v4.0.0 已经被移除。"),
|
|
31
|
+
)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""文本转语音命令"""
|
|
2
|
+
|
|
3
|
+
from astrbot.api import star
|
|
4
|
+
from astrbot.api.event import AstrMessageEvent, MessageEventResult
|
|
5
|
+
from astrbot.core.star.session_llm_manager import SessionServiceManager
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class TTSCommand:
|
|
9
|
+
"""文本转语音命令类"""
|
|
10
|
+
|
|
11
|
+
def __init__(self, context: star.Context):
|
|
12
|
+
self.context = context
|
|
13
|
+
|
|
14
|
+
async def tts(self, event: AstrMessageEvent):
|
|
15
|
+
"""开关文本转语音(会话级别)"""
|
|
16
|
+
umo = event.unified_msg_origin
|
|
17
|
+
ses_tts = SessionServiceManager.is_tts_enabled_for_session(umo)
|
|
18
|
+
cfg = self.context.get_config(umo=umo)
|
|
19
|
+
tts_enable = cfg["provider_tts_settings"]["enable"]
|
|
20
|
+
|
|
21
|
+
# 切换状态
|
|
22
|
+
new_status = not ses_tts
|
|
23
|
+
SessionServiceManager.set_tts_status_for_session(umo, new_status)
|
|
24
|
+
|
|
25
|
+
status_text = "已开启" if new_status else "已关闭"
|
|
26
|
+
|
|
27
|
+
if new_status and not tts_enable:
|
|
28
|
+
event.set_result(
|
|
29
|
+
MessageEventResult().message(
|
|
30
|
+
f"{status_text}当前会话的文本转语音。但 TTS 功能在配置中未启用,请前往 WebUI 开启。",
|
|
31
|
+
),
|
|
32
|
+
)
|
|
33
|
+
else:
|
|
34
|
+
event.set_result(
|
|
35
|
+
MessageEventResult().message(f"{status_text}当前会话的文本转语音。"),
|
|
36
|
+
)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class RstScene(Enum):
|
|
5
|
+
GROUP_UNIQUE_ON = ("group_unique_on", "群聊+会话隔离开启")
|
|
6
|
+
GROUP_UNIQUE_OFF = ("group_unique_off", "群聊+会话隔离关闭")
|
|
7
|
+
PRIVATE = ("private", "私聊")
|
|
8
|
+
|
|
9
|
+
@property
|
|
10
|
+
def key(self) -> str:
|
|
11
|
+
return self.value[0]
|
|
12
|
+
|
|
13
|
+
@property
|
|
14
|
+
def name(self) -> str:
|
|
15
|
+
return self.value[1]
|
|
16
|
+
|
|
17
|
+
@classmethod
|
|
18
|
+
def from_index(cls, index: int) -> "RstScene":
|
|
19
|
+
mapping = {1: cls.GROUP_UNIQUE_ON, 2: cls.GROUP_UNIQUE_OFF, 3: cls.PRIVATE}
|
|
20
|
+
return mapping[index]
|
|
21
|
+
|
|
22
|
+
@classmethod
|
|
23
|
+
def get_scene(cls, is_group: bool, is_unique_session: bool) -> "RstScene":
|
|
24
|
+
if is_group:
|
|
25
|
+
return cls.GROUP_UNIQUE_ON if is_unique_session else cls.GROUP_UNIQUE_OFF
|
|
26
|
+
return cls.PRIVATE
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
from astrbot.api import star
|
|
2
|
+
from astrbot.api.event import AstrMessageEvent, filter
|
|
3
|
+
|
|
4
|
+
from .commands import (
|
|
5
|
+
AdminCommands,
|
|
6
|
+
AlterCmdCommands,
|
|
7
|
+
ConversationCommands,
|
|
8
|
+
HelpCommand,
|
|
9
|
+
LLMCommands,
|
|
10
|
+
PersonaCommands,
|
|
11
|
+
PluginCommands,
|
|
12
|
+
ProviderCommands,
|
|
13
|
+
SetUnsetCommands,
|
|
14
|
+
SIDCommand,
|
|
15
|
+
T2ICommand,
|
|
16
|
+
ToolCommands,
|
|
17
|
+
TTSCommand,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class Main(star.Star):
|
|
22
|
+
def __init__(self, context: star.Context) -> None:
|
|
23
|
+
self.context = context
|
|
24
|
+
|
|
25
|
+
self.help_c = HelpCommand(self.context)
|
|
26
|
+
self.llm_c = LLMCommands(self.context)
|
|
27
|
+
self.tool_c = ToolCommands(self.context)
|
|
28
|
+
self.plugin_c = PluginCommands(self.context)
|
|
29
|
+
self.admin_c = AdminCommands(self.context)
|
|
30
|
+
self.conversation_c = ConversationCommands(self.context)
|
|
31
|
+
self.provider_c = ProviderCommands(self.context)
|
|
32
|
+
self.persona_c = PersonaCommands(self.context)
|
|
33
|
+
self.alter_cmd_c = AlterCmdCommands(self.context)
|
|
34
|
+
self.setunset_c = SetUnsetCommands(self.context)
|
|
35
|
+
self.t2i_c = T2ICommand(self.context)
|
|
36
|
+
self.tts_c = TTSCommand(self.context)
|
|
37
|
+
self.sid_c = SIDCommand(self.context)
|
|
38
|
+
|
|
39
|
+
@filter.command("help")
|
|
40
|
+
async def help(self, event: AstrMessageEvent):
|
|
41
|
+
"""查看帮助"""
|
|
42
|
+
await self.help_c.help(event)
|
|
43
|
+
|
|
44
|
+
@filter.permission_type(filter.PermissionType.ADMIN)
|
|
45
|
+
@filter.command("llm")
|
|
46
|
+
async def llm(self, event: AstrMessageEvent):
|
|
47
|
+
"""开启/关闭 LLM"""
|
|
48
|
+
await self.llm_c.llm(event)
|
|
49
|
+
|
|
50
|
+
@filter.command_group("tool")
|
|
51
|
+
def tool(self):
|
|
52
|
+
"""函数工具管理"""
|
|
53
|
+
|
|
54
|
+
@tool.command("ls")
|
|
55
|
+
async def tool_ls(self, event: AstrMessageEvent):
|
|
56
|
+
"""查看函数工具列表"""
|
|
57
|
+
await self.tool_c.tool_ls(event)
|
|
58
|
+
|
|
59
|
+
@tool.command("on")
|
|
60
|
+
async def tool_on(self, event: AstrMessageEvent, tool_name: str):
|
|
61
|
+
"""启用一个函数工具"""
|
|
62
|
+
await self.tool_c.tool_on(event, tool_name)
|
|
63
|
+
|
|
64
|
+
@tool.command("off")
|
|
65
|
+
async def tool_off(self, event: AstrMessageEvent, tool_name: str):
|
|
66
|
+
"""停用一个函数工具"""
|
|
67
|
+
await self.tool_c.tool_off(event, tool_name)
|
|
68
|
+
|
|
69
|
+
@tool.command("off_all")
|
|
70
|
+
async def tool_all_off(self, event: AstrMessageEvent):
|
|
71
|
+
"""停用所有函数工具"""
|
|
72
|
+
await self.tool_c.tool_all_off(event)
|
|
73
|
+
|
|
74
|
+
@filter.command_group("plugin")
|
|
75
|
+
def plugin(self):
|
|
76
|
+
"""插件管理"""
|
|
77
|
+
|
|
78
|
+
@plugin.command("ls")
|
|
79
|
+
async def plugin_ls(self, event: AstrMessageEvent):
|
|
80
|
+
"""获取已经安装的插件列表。"""
|
|
81
|
+
await self.plugin_c.plugin_ls(event)
|
|
82
|
+
|
|
83
|
+
@filter.permission_type(filter.PermissionType.ADMIN)
|
|
84
|
+
@plugin.command("off")
|
|
85
|
+
async def plugin_off(self, event: AstrMessageEvent, plugin_name: str = ""):
|
|
86
|
+
"""禁用插件"""
|
|
87
|
+
await self.plugin_c.plugin_off(event, plugin_name)
|
|
88
|
+
|
|
89
|
+
@filter.permission_type(filter.PermissionType.ADMIN)
|
|
90
|
+
@plugin.command("on")
|
|
91
|
+
async def plugin_on(self, event: AstrMessageEvent, plugin_name: str = ""):
|
|
92
|
+
"""启用插件"""
|
|
93
|
+
await self.plugin_c.plugin_on(event, plugin_name)
|
|
94
|
+
|
|
95
|
+
@filter.permission_type(filter.PermissionType.ADMIN)
|
|
96
|
+
@plugin.command("get")
|
|
97
|
+
async def plugin_get(self, event: AstrMessageEvent, plugin_repo: str = ""):
|
|
98
|
+
"""安装插件"""
|
|
99
|
+
await self.plugin_c.plugin_get(event, plugin_repo)
|
|
100
|
+
|
|
101
|
+
@plugin.command("help")
|
|
102
|
+
async def plugin_help(self, event: AstrMessageEvent, plugin_name: str = ""):
|
|
103
|
+
"""获取插件帮助"""
|
|
104
|
+
await self.plugin_c.plugin_help(event, plugin_name)
|
|
105
|
+
|
|
106
|
+
@filter.command("t2i")
|
|
107
|
+
async def t2i(self, event: AstrMessageEvent):
|
|
108
|
+
"""开关文本转图片"""
|
|
109
|
+
await self.t2i_c.t2i(event)
|
|
110
|
+
|
|
111
|
+
@filter.command("tts")
|
|
112
|
+
async def tts(self, event: AstrMessageEvent):
|
|
113
|
+
"""开关文本转语音(会话级别)"""
|
|
114
|
+
await self.tts_c.tts(event)
|
|
115
|
+
|
|
116
|
+
@filter.command("sid")
|
|
117
|
+
async def sid(self, event: AstrMessageEvent):
|
|
118
|
+
"""获取会话 ID 和 管理员 ID"""
|
|
119
|
+
await self.sid_c.sid(event)
|
|
120
|
+
|
|
121
|
+
@filter.permission_type(filter.PermissionType.ADMIN)
|
|
122
|
+
@filter.command("op")
|
|
123
|
+
async def op(self, event: AstrMessageEvent, admin_id: str = ""):
|
|
124
|
+
"""授权管理员。op <admin_id>"""
|
|
125
|
+
await self.admin_c.op(event, admin_id)
|
|
126
|
+
|
|
127
|
+
@filter.permission_type(filter.PermissionType.ADMIN)
|
|
128
|
+
@filter.command("deop")
|
|
129
|
+
async def deop(self, event: AstrMessageEvent, admin_id: str):
|
|
130
|
+
"""取消授权管理员。deop <admin_id>"""
|
|
131
|
+
await self.admin_c.deop(event, admin_id)
|
|
132
|
+
|
|
133
|
+
@filter.permission_type(filter.PermissionType.ADMIN)
|
|
134
|
+
@filter.command("wl")
|
|
135
|
+
async def wl(self, event: AstrMessageEvent, sid: str = ""):
|
|
136
|
+
"""添加白名单。wl <sid>"""
|
|
137
|
+
await self.admin_c.wl(event, sid)
|
|
138
|
+
|
|
139
|
+
@filter.permission_type(filter.PermissionType.ADMIN)
|
|
140
|
+
@filter.command("dwl")
|
|
141
|
+
async def dwl(self, event: AstrMessageEvent, sid: str):
|
|
142
|
+
"""删除白名单。dwl <sid>"""
|
|
143
|
+
await self.admin_c.dwl(event, sid)
|
|
144
|
+
|
|
145
|
+
@filter.permission_type(filter.PermissionType.ADMIN)
|
|
146
|
+
@filter.command("provider")
|
|
147
|
+
async def provider(
|
|
148
|
+
self,
|
|
149
|
+
event: AstrMessageEvent,
|
|
150
|
+
idx: str | int | None = None,
|
|
151
|
+
idx2: int | None = None,
|
|
152
|
+
):
|
|
153
|
+
"""查看或者切换 LLM Provider"""
|
|
154
|
+
await self.provider_c.provider(event, idx, idx2)
|
|
155
|
+
|
|
156
|
+
@filter.command("reset")
|
|
157
|
+
async def reset(self, message: AstrMessageEvent):
|
|
158
|
+
"""重置 LLM 会话"""
|
|
159
|
+
await self.conversation_c.reset(message)
|
|
160
|
+
|
|
161
|
+
@filter.permission_type(filter.PermissionType.ADMIN)
|
|
162
|
+
@filter.command("model")
|
|
163
|
+
async def model_ls(
|
|
164
|
+
self,
|
|
165
|
+
message: AstrMessageEvent,
|
|
166
|
+
idx_or_name: int | str | None = None,
|
|
167
|
+
):
|
|
168
|
+
"""查看或者切换模型"""
|
|
169
|
+
await self.provider_c.model_ls(message, idx_or_name)
|
|
170
|
+
|
|
171
|
+
@filter.command("history")
|
|
172
|
+
async def his(self, message: AstrMessageEvent, page: int = 1):
|
|
173
|
+
"""查看对话记录"""
|
|
174
|
+
await self.conversation_c.his(message, page)
|
|
175
|
+
|
|
176
|
+
@filter.command("ls")
|
|
177
|
+
async def convs(self, message: AstrMessageEvent, page: int = 1):
|
|
178
|
+
"""查看对话列表"""
|
|
179
|
+
await self.conversation_c.convs(message, page)
|
|
180
|
+
|
|
181
|
+
@filter.command("new")
|
|
182
|
+
async def new_conv(self, message: AstrMessageEvent):
|
|
183
|
+
"""创建新对话"""
|
|
184
|
+
await self.conversation_c.new_conv(message)
|
|
185
|
+
|
|
186
|
+
@filter.permission_type(filter.PermissionType.ADMIN)
|
|
187
|
+
@filter.command("groupnew")
|
|
188
|
+
async def groupnew_conv(self, message: AstrMessageEvent, sid: str):
|
|
189
|
+
"""创建新群聊对话"""
|
|
190
|
+
await self.conversation_c.groupnew_conv(message, sid)
|
|
191
|
+
|
|
192
|
+
@filter.command("switch")
|
|
193
|
+
async def switch_conv(self, message: AstrMessageEvent, index: int | None = None):
|
|
194
|
+
"""通过 /ls 前面的序号切换对话"""
|
|
195
|
+
await self.conversation_c.switch_conv(message, index)
|
|
196
|
+
|
|
197
|
+
@filter.command("rename")
|
|
198
|
+
async def rename_conv(self, message: AstrMessageEvent, new_name: str):
|
|
199
|
+
"""重命名对话"""
|
|
200
|
+
await self.conversation_c.rename_conv(message, new_name)
|
|
201
|
+
|
|
202
|
+
@filter.command("del")
|
|
203
|
+
async def del_conv(self, message: AstrMessageEvent):
|
|
204
|
+
"""删除当前对话"""
|
|
205
|
+
await self.conversation_c.del_conv(message)
|
|
206
|
+
|
|
207
|
+
@filter.permission_type(filter.PermissionType.ADMIN)
|
|
208
|
+
@filter.command("key")
|
|
209
|
+
async def key(self, message: AstrMessageEvent, index: int | None = None):
|
|
210
|
+
"""查看或者切换 Key"""
|
|
211
|
+
await self.provider_c.key(message, index)
|
|
212
|
+
|
|
213
|
+
@filter.permission_type(filter.PermissionType.ADMIN)
|
|
214
|
+
@filter.command("persona")
|
|
215
|
+
async def persona(self, message: AstrMessageEvent):
|
|
216
|
+
"""查看或者切换 Persona"""
|
|
217
|
+
await self.persona_c.persona(message)
|
|
218
|
+
|
|
219
|
+
@filter.permission_type(filter.PermissionType.ADMIN)
|
|
220
|
+
@filter.command("dashboard_update")
|
|
221
|
+
async def update_dashboard(self, event: AstrMessageEvent):
|
|
222
|
+
"""更新管理面板"""
|
|
223
|
+
await self.admin_c.update_dashboard(event)
|
|
224
|
+
|
|
225
|
+
@filter.command("set")
|
|
226
|
+
async def set_variable(self, event: AstrMessageEvent, key: str, value: str):
|
|
227
|
+
await self.setunset_c.set_variable(event, key, value)
|
|
228
|
+
|
|
229
|
+
@filter.command("unset")
|
|
230
|
+
async def unset_variable(self, event: AstrMessageEvent, key: str):
|
|
231
|
+
await self.setunset_c.unset_variable(event, key)
|
|
232
|
+
|
|
233
|
+
@filter.permission_type(filter.PermissionType.ADMIN)
|
|
234
|
+
@filter.command("alter_cmd", alias={"alter"})
|
|
235
|
+
async def alter_cmd(self, event: AstrMessageEvent):
|
|
236
|
+
"""修改命令权限"""
|
|
237
|
+
await self.alter_cmd_c.alter_cmd(event)
|