AstrBot 4.5.3__py3-none-any.whl → 4.5.7__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/all.py +2 -1
- astrbot/api/provider/__init__.py +2 -1
- astrbot/core/agent/run_context.py +7 -2
- astrbot/core/agent/runners/base.py +7 -0
- astrbot/core/agent/runners/tool_loop_agent_runner.py +51 -3
- astrbot/core/agent/tool.py +5 -6
- astrbot/core/astr_agent_context.py +13 -8
- astrbot/core/astr_agent_hooks.py +36 -0
- astrbot/core/astr_agent_run_util.py +80 -0
- astrbot/core/astr_agent_tool_exec.py +246 -0
- astrbot/core/config/default.py +53 -7
- astrbot/core/exceptions.py +9 -0
- astrbot/core/pipeline/context.py +1 -2
- astrbot/core/pipeline/context_utils.py +0 -65
- astrbot/core/pipeline/process_stage/method/llm_request.py +239 -491
- astrbot/core/pipeline/respond/stage.py +21 -20
- astrbot/core/platform/platform_metadata.py +3 -0
- astrbot/core/platform/register.py +2 -0
- astrbot/core/platform/sources/aiocqhttp/aiocqhttp_platform_adapter.py +2 -0
- astrbot/core/platform/sources/dingtalk/dingtalk_adapter.py +16 -5
- astrbot/core/platform/sources/discord/discord_platform_adapter.py +4 -1
- astrbot/core/platform/sources/discord/discord_platform_event.py +16 -7
- astrbot/core/platform/sources/lark/lark_adapter.py +4 -1
- astrbot/core/platform/sources/misskey/misskey_adapter.py +4 -1
- astrbot/core/platform/sources/satori/satori_adapter.py +2 -2
- astrbot/core/platform/sources/slack/slack_adapter.py +2 -0
- astrbot/core/platform/sources/webchat/webchat_adapter.py +3 -0
- astrbot/core/platform/sources/webchat/webchat_event.py +8 -1
- astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py +4 -1
- astrbot/core/platform/sources/wechatpadpro/wechatpadpro_message_event.py +16 -0
- astrbot/core/platform/sources/wecom/wecom_adapter.py +2 -1
- astrbot/core/platform/sources/weixin_official_account/weixin_offacc_adapter.py +4 -1
- astrbot/core/provider/__init__.py +2 -2
- astrbot/core/provider/entities.py +40 -18
- astrbot/core/provider/func_tool_manager.py +15 -6
- astrbot/core/provider/manager.py +4 -1
- astrbot/core/provider/provider.py +7 -22
- astrbot/core/provider/register.py +2 -0
- astrbot/core/provider/sources/anthropic_source.py +0 -2
- astrbot/core/provider/sources/coze_source.py +0 -2
- astrbot/core/provider/sources/dashscope_source.py +1 -3
- astrbot/core/provider/sources/dify_source.py +0 -2
- astrbot/core/provider/sources/gemini_source.py +31 -3
- astrbot/core/provider/sources/groq_source.py +15 -0
- astrbot/core/provider/sources/openai_source.py +67 -21
- astrbot/core/provider/sources/zhipu_source.py +1 -6
- astrbot/core/star/context.py +197 -45
- astrbot/core/star/register/star_handler.py +30 -10
- astrbot/dashboard/routes/chat.py +5 -0
- {astrbot-4.5.3.dist-info → astrbot-4.5.7.dist-info}/METADATA +55 -65
- {astrbot-4.5.3.dist-info → astrbot-4.5.7.dist-info}/RECORD +54 -49
- {astrbot-4.5.3.dist-info → astrbot-4.5.7.dist-info}/WHEEL +0 -0
- {astrbot-4.5.3.dist-info → astrbot-4.5.7.dist-info}/entry_points.txt +0 -0
- {astrbot-4.5.3.dist-info → astrbot-4.5.7.dist-info}/licenses/LICENSE +0 -0
astrbot/core/star/context.py
CHANGED
|
@@ -5,6 +5,10 @@ from typing import Any
|
|
|
5
5
|
|
|
6
6
|
from deprecated import deprecated
|
|
7
7
|
|
|
8
|
+
from astrbot.core.agent.hooks import BaseAgentRunHooks
|
|
9
|
+
from astrbot.core.agent.message import Message
|
|
10
|
+
from astrbot.core.agent.runners.tool_loop_agent_runner import ToolLoopAgentRunner
|
|
11
|
+
from astrbot.core.agent.tool import ToolSet
|
|
8
12
|
from astrbot.core.astrbot_config_mgr import AstrBotConfigManager
|
|
9
13
|
from astrbot.core.config.astrbot_config import AstrBotConfig
|
|
10
14
|
from astrbot.core.conversation_mgr import ConversationManager
|
|
@@ -13,10 +17,10 @@ from astrbot.core.knowledge_base.kb_mgr import KnowledgeBaseManager
|
|
|
13
17
|
from astrbot.core.message.message_event_result import MessageChain
|
|
14
18
|
from astrbot.core.persona_mgr import PersonaManager
|
|
15
19
|
from astrbot.core.platform import Platform
|
|
16
|
-
from astrbot.core.platform.astr_message_event import MessageSesion
|
|
20
|
+
from astrbot.core.platform.astr_message_event import AstrMessageEvent, MessageSesion
|
|
17
21
|
from astrbot.core.platform.manager import PlatformManager
|
|
18
22
|
from astrbot.core.platform_message_history_mgr import PlatformMessageHistoryManager
|
|
19
|
-
from astrbot.core.provider.entities import ProviderType
|
|
23
|
+
from astrbot.core.provider.entities import LLMResponse, ProviderRequest, ProviderType
|
|
20
24
|
from astrbot.core.provider.func_tool_manager import FunctionTool, FunctionToolManager
|
|
21
25
|
from astrbot.core.provider.manager import ProviderManager
|
|
22
26
|
from astrbot.core.provider.provider import (
|
|
@@ -31,6 +35,7 @@ from astrbot.core.star.filter.platform_adapter_type import (
|
|
|
31
35
|
PlatformAdapterType,
|
|
32
36
|
)
|
|
33
37
|
|
|
38
|
+
from ..exceptions import ProviderNotFoundError
|
|
34
39
|
from .filter.command import CommandFilter
|
|
35
40
|
from .filter.regex import RegexFilter
|
|
36
41
|
from .star import StarMetadata, star_map, star_registry
|
|
@@ -75,6 +80,153 @@ class Context:
|
|
|
75
80
|
self.astrbot_config_mgr = astrbot_config_mgr
|
|
76
81
|
self.kb_manager = knowledge_base_manager
|
|
77
82
|
|
|
83
|
+
async def llm_generate(
|
|
84
|
+
self,
|
|
85
|
+
*,
|
|
86
|
+
chat_provider_id: str,
|
|
87
|
+
prompt: str | None = None,
|
|
88
|
+
image_urls: list[str] | None = None,
|
|
89
|
+
tools: ToolSet | None = None,
|
|
90
|
+
system_prompt: str | None = None,
|
|
91
|
+
contexts: list[Message] | None = None,
|
|
92
|
+
**kwargs: Any,
|
|
93
|
+
) -> LLMResponse:
|
|
94
|
+
"""Call the LLM to generate a response. The method will not automatically execute tool calls. If you want to use tool calls, please use `tool_loop_agent()`.
|
|
95
|
+
|
|
96
|
+
.. versionadded:: 4.5.7 (sdk)
|
|
97
|
+
|
|
98
|
+
Args:
|
|
99
|
+
chat_provider_id: The chat provider ID to use.
|
|
100
|
+
prompt: The prompt to send to the LLM, if `contexts` and `prompt` are both provided, `prompt` will be appended as the last user message
|
|
101
|
+
image_urls: List of image URLs to include in the prompt, if `contexts` and `prompt` are both provided, `image_urls` will be appended to the last user message
|
|
102
|
+
tools: ToolSet of tools available to the LLM
|
|
103
|
+
system_prompt: System prompt to guide the LLM's behavior, if provided, it will always insert as the first system message in the context
|
|
104
|
+
contexts: context messages for the LLM
|
|
105
|
+
**kwargs: Additional keyword arguments for LLM generation, OpenAI compatible
|
|
106
|
+
|
|
107
|
+
Raises:
|
|
108
|
+
ChatProviderNotFoundError: If the specified chat provider ID is not found
|
|
109
|
+
Exception: For other errors during LLM generation
|
|
110
|
+
"""
|
|
111
|
+
prov = await self.provider_manager.get_provider_by_id(chat_provider_id)
|
|
112
|
+
if not prov or not isinstance(prov, Provider):
|
|
113
|
+
raise ProviderNotFoundError(f"Provider {chat_provider_id} not found")
|
|
114
|
+
llm_resp = await prov.text_chat(
|
|
115
|
+
prompt=prompt,
|
|
116
|
+
image_urls=image_urls,
|
|
117
|
+
func_tool=tools,
|
|
118
|
+
contexts=contexts,
|
|
119
|
+
system_prompt=system_prompt,
|
|
120
|
+
**kwargs,
|
|
121
|
+
)
|
|
122
|
+
return llm_resp
|
|
123
|
+
|
|
124
|
+
async def tool_loop_agent(
|
|
125
|
+
self,
|
|
126
|
+
*,
|
|
127
|
+
event: AstrMessageEvent,
|
|
128
|
+
chat_provider_id: str,
|
|
129
|
+
prompt: str | None = None,
|
|
130
|
+
image_urls: list[str] | None = None,
|
|
131
|
+
tools: ToolSet | None = None,
|
|
132
|
+
system_prompt: str | None = None,
|
|
133
|
+
contexts: list[Message] | None = None,
|
|
134
|
+
max_steps: int = 30,
|
|
135
|
+
tool_call_timeout: int = 60,
|
|
136
|
+
**kwargs: Any,
|
|
137
|
+
) -> LLMResponse:
|
|
138
|
+
"""Run an agent loop that allows the LLM to call tools iteratively until a final answer is produced.
|
|
139
|
+
If you do not pass the agent_context parameter, the method will recreate a new agent context.
|
|
140
|
+
|
|
141
|
+
.. versionadded:: 4.5.7 (sdk)
|
|
142
|
+
|
|
143
|
+
Args:
|
|
144
|
+
chat_provider_id: The chat provider ID to use.
|
|
145
|
+
prompt: The prompt to send to the LLM, if `contexts` and `prompt` are both provided, `prompt` will be appended as the last user message
|
|
146
|
+
image_urls: List of image URLs to include in the prompt, if `contexts` and `prompt` are both provided, `image_urls` will be appended to the last user message
|
|
147
|
+
tools: ToolSet of tools available to the LLM
|
|
148
|
+
system_prompt: System prompt to guide the LLM's behavior, if provided, it will always insert as the first system message in the context
|
|
149
|
+
contexts: context messages for the LLM
|
|
150
|
+
max_steps: Maximum number of tool calls before stopping the loop
|
|
151
|
+
**kwargs: Additional keyword arguments. The kwargs will not be passed to the LLM directly for now, but can include:
|
|
152
|
+
agent_hooks: BaseAgentRunHooks[AstrAgentContext] - hooks to run during agent execution
|
|
153
|
+
agent_context: AstrAgentContext - context to use for the agent
|
|
154
|
+
|
|
155
|
+
Returns:
|
|
156
|
+
The final LLMResponse after tool calls are completed.
|
|
157
|
+
|
|
158
|
+
Raises:
|
|
159
|
+
ChatProviderNotFoundError: If the specified chat provider ID is not found
|
|
160
|
+
Exception: For other errors during LLM generation
|
|
161
|
+
"""
|
|
162
|
+
# Import here to avoid circular imports
|
|
163
|
+
from astrbot.core.astr_agent_context import (
|
|
164
|
+
AgentContextWrapper,
|
|
165
|
+
AstrAgentContext,
|
|
166
|
+
)
|
|
167
|
+
from astrbot.core.astr_agent_tool_exec import FunctionToolExecutor
|
|
168
|
+
|
|
169
|
+
prov = await self.provider_manager.get_provider_by_id(chat_provider_id)
|
|
170
|
+
if not prov or not isinstance(prov, Provider):
|
|
171
|
+
raise ProviderNotFoundError(f"Provider {chat_provider_id} not found")
|
|
172
|
+
|
|
173
|
+
agent_hooks = kwargs.get("agent_hooks") or BaseAgentRunHooks[AstrAgentContext]()
|
|
174
|
+
agent_context = kwargs.get("agent_context")
|
|
175
|
+
|
|
176
|
+
context_ = []
|
|
177
|
+
for msg in contexts or []:
|
|
178
|
+
if isinstance(msg, Message):
|
|
179
|
+
context_.append(msg.model_dump())
|
|
180
|
+
else:
|
|
181
|
+
context_.append(msg)
|
|
182
|
+
|
|
183
|
+
request = ProviderRequest(
|
|
184
|
+
prompt=prompt,
|
|
185
|
+
image_urls=image_urls or [],
|
|
186
|
+
func_tool=tools,
|
|
187
|
+
contexts=context_,
|
|
188
|
+
system_prompt=system_prompt or "",
|
|
189
|
+
)
|
|
190
|
+
if agent_context is None:
|
|
191
|
+
agent_context = AstrAgentContext(
|
|
192
|
+
context=self,
|
|
193
|
+
event=event,
|
|
194
|
+
)
|
|
195
|
+
agent_runner = ToolLoopAgentRunner()
|
|
196
|
+
tool_executor = FunctionToolExecutor()
|
|
197
|
+
await agent_runner.reset(
|
|
198
|
+
provider=prov,
|
|
199
|
+
request=request,
|
|
200
|
+
run_context=AgentContextWrapper(
|
|
201
|
+
context=agent_context,
|
|
202
|
+
tool_call_timeout=tool_call_timeout,
|
|
203
|
+
),
|
|
204
|
+
tool_executor=tool_executor,
|
|
205
|
+
agent_hooks=agent_hooks,
|
|
206
|
+
streaming=kwargs.get("stream", False),
|
|
207
|
+
)
|
|
208
|
+
async for _ in agent_runner.step_until_done(max_steps):
|
|
209
|
+
pass
|
|
210
|
+
llm_resp = agent_runner.get_final_llm_resp()
|
|
211
|
+
if not llm_resp:
|
|
212
|
+
raise Exception("Agent did not produce a final LLM response")
|
|
213
|
+
return llm_resp
|
|
214
|
+
|
|
215
|
+
async def get_current_chat_provider_id(self, umo: str) -> str:
|
|
216
|
+
"""Get the ID of the currently used chat provider.
|
|
217
|
+
|
|
218
|
+
Args:
|
|
219
|
+
umo(str): unified_message_origin value, if provided and user has enabled provider session isolation, the provider preferred by that session will be used.
|
|
220
|
+
|
|
221
|
+
Raises:
|
|
222
|
+
ProviderNotFoundError: If the specified chat provider is not found
|
|
223
|
+
|
|
224
|
+
"""
|
|
225
|
+
prov = self.get_using_provider(umo)
|
|
226
|
+
if not prov:
|
|
227
|
+
raise ProviderNotFoundError("Provider not found")
|
|
228
|
+
return prov.meta().id
|
|
229
|
+
|
|
78
230
|
def get_registered_star(self, star_name: str) -> StarMetadata | None:
|
|
79
231
|
"""根据插件名获取插件的 Metadata"""
|
|
80
232
|
for star in star_registry:
|
|
@@ -107,10 +259,6 @@ class Context:
|
|
|
107
259
|
"""
|
|
108
260
|
return self.provider_manager.llm_tools.deactivate_llm_tool(name)
|
|
109
261
|
|
|
110
|
-
def register_provider(self, provider: Provider):
|
|
111
|
-
"""注册一个 LLM Provider(Chat_Completion 类型)。"""
|
|
112
|
-
self.provider_manager.provider_insts.append(provider)
|
|
113
|
-
|
|
114
262
|
def get_provider_by_id(
|
|
115
263
|
self,
|
|
116
264
|
provider_id: str,
|
|
@@ -189,45 +337,6 @@ class Context:
|
|
|
189
337
|
return self._config
|
|
190
338
|
return self.astrbot_config_mgr.get_conf(umo)
|
|
191
339
|
|
|
192
|
-
def get_db(self) -> BaseDatabase:
|
|
193
|
-
"""获取 AstrBot 数据库。"""
|
|
194
|
-
return self._db
|
|
195
|
-
|
|
196
|
-
def get_event_queue(self) -> Queue:
|
|
197
|
-
"""获取事件队列。"""
|
|
198
|
-
return self._event_queue
|
|
199
|
-
|
|
200
|
-
@deprecated(version="4.0.0", reason="Use get_platform_inst instead")
|
|
201
|
-
def get_platform(self, platform_type: PlatformAdapterType | str) -> Platform | None:
|
|
202
|
-
"""获取指定类型的平台适配器。
|
|
203
|
-
|
|
204
|
-
该方法已经过时,请使用 get_platform_inst 方法。(>= AstrBot v4.0.0)
|
|
205
|
-
"""
|
|
206
|
-
for platform in self.platform_manager.platform_insts:
|
|
207
|
-
name = platform.meta().name
|
|
208
|
-
if isinstance(platform_type, str):
|
|
209
|
-
if name == platform_type:
|
|
210
|
-
return platform
|
|
211
|
-
elif (
|
|
212
|
-
name in ADAPTER_NAME_2_TYPE
|
|
213
|
-
and ADAPTER_NAME_2_TYPE[name] & platform_type
|
|
214
|
-
):
|
|
215
|
-
return platform
|
|
216
|
-
|
|
217
|
-
def get_platform_inst(self, platform_id: str) -> Platform | None:
|
|
218
|
-
"""获取指定 ID 的平台适配器实例。
|
|
219
|
-
|
|
220
|
-
Args:
|
|
221
|
-
platform_id (str): 平台适配器的唯一标识符。你可以通过 event.get_platform_id() 获取。
|
|
222
|
-
|
|
223
|
-
Returns:
|
|
224
|
-
Platform: 平台适配器实例,如果未找到则返回 None。
|
|
225
|
-
|
|
226
|
-
"""
|
|
227
|
-
for platform in self.platform_manager.platform_insts:
|
|
228
|
-
if platform.meta().id == platform_id:
|
|
229
|
-
return platform
|
|
230
|
-
|
|
231
340
|
async def send_message(
|
|
232
341
|
self,
|
|
233
342
|
session: str | MessageSesion,
|
|
@@ -300,6 +409,49 @@ class Context:
|
|
|
300
409
|
以下的方法已经不推荐使用。请从 AstrBot 文档查看更好的注册方式。
|
|
301
410
|
"""
|
|
302
411
|
|
|
412
|
+
def get_event_queue(self) -> Queue:
|
|
413
|
+
"""获取事件队列。"""
|
|
414
|
+
return self._event_queue
|
|
415
|
+
|
|
416
|
+
@deprecated(version="4.0.0", reason="Use get_platform_inst instead")
|
|
417
|
+
def get_platform(self, platform_type: PlatformAdapterType | str) -> Platform | None:
|
|
418
|
+
"""获取指定类型的平台适配器。
|
|
419
|
+
|
|
420
|
+
该方法已经过时,请使用 get_platform_inst 方法。(>= AstrBot v4.0.0)
|
|
421
|
+
"""
|
|
422
|
+
for platform in self.platform_manager.platform_insts:
|
|
423
|
+
name = platform.meta().name
|
|
424
|
+
if isinstance(platform_type, str):
|
|
425
|
+
if name == platform_type:
|
|
426
|
+
return platform
|
|
427
|
+
elif (
|
|
428
|
+
name in ADAPTER_NAME_2_TYPE
|
|
429
|
+
and ADAPTER_NAME_2_TYPE[name] & platform_type
|
|
430
|
+
):
|
|
431
|
+
return platform
|
|
432
|
+
|
|
433
|
+
def get_platform_inst(self, platform_id: str) -> Platform | None:
|
|
434
|
+
"""获取指定 ID 的平台适配器实例。
|
|
435
|
+
|
|
436
|
+
Args:
|
|
437
|
+
platform_id (str): 平台适配器的唯一标识符。你可以通过 event.get_platform_id() 获取。
|
|
438
|
+
|
|
439
|
+
Returns:
|
|
440
|
+
Platform: 平台适配器实例,如果未找到则返回 None。
|
|
441
|
+
|
|
442
|
+
"""
|
|
443
|
+
for platform in self.platform_manager.platform_insts:
|
|
444
|
+
if platform.meta().id == platform_id:
|
|
445
|
+
return platform
|
|
446
|
+
|
|
447
|
+
def get_db(self) -> BaseDatabase:
|
|
448
|
+
"""获取 AstrBot 数据库。"""
|
|
449
|
+
return self._db
|
|
450
|
+
|
|
451
|
+
def register_provider(self, provider: Provider):
|
|
452
|
+
"""注册一个 LLM Provider(Chat_Completion 类型)。"""
|
|
453
|
+
self.provider_manager.provider_insts.append(provider)
|
|
454
|
+
|
|
303
455
|
def register_llm_tool(
|
|
304
456
|
self,
|
|
305
457
|
name: str,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
import re
|
|
3
4
|
from collections.abc import Awaitable, Callable
|
|
4
5
|
from typing import Any
|
|
5
6
|
|
|
@@ -11,7 +12,7 @@ from astrbot.core.agent.handoff import HandoffTool
|
|
|
11
12
|
from astrbot.core.agent.hooks import BaseAgentRunHooks
|
|
12
13
|
from astrbot.core.agent.tool import FunctionTool
|
|
13
14
|
from astrbot.core.astr_agent_context import AstrAgentContext
|
|
14
|
-
from astrbot.core.provider.func_tool_manager import SUPPORTED_TYPES
|
|
15
|
+
from astrbot.core.provider.func_tool_manager import PY_TO_JSON_TYPE, SUPPORTED_TYPES
|
|
15
16
|
from astrbot.core.provider.register import llm_tools
|
|
16
17
|
|
|
17
18
|
from ..filter.command import CommandFilter
|
|
@@ -417,18 +418,37 @@ def register_llm_tool(name: str | None = None, **kwargs):
|
|
|
417
418
|
docstring = docstring_parser.parse(func_doc)
|
|
418
419
|
args = []
|
|
419
420
|
for arg in docstring.params:
|
|
420
|
-
|
|
421
|
+
sub_type_name = None
|
|
422
|
+
type_name = arg.type_name
|
|
423
|
+
if not type_name:
|
|
424
|
+
raise ValueError(
|
|
425
|
+
f"LLM 函数工具 {awaitable.__module__}_{llm_tool_name} 的参数 {arg.arg_name} 缺少类型注释。",
|
|
426
|
+
)
|
|
427
|
+
# parse type_name to handle cases like "list[string]"
|
|
428
|
+
match = re.match(r"(\w+)\[(\w+)\]", type_name)
|
|
429
|
+
if match:
|
|
430
|
+
type_name = match.group(1)
|
|
431
|
+
sub_type_name = match.group(2)
|
|
432
|
+
type_name = PY_TO_JSON_TYPE.get(type_name, type_name)
|
|
433
|
+
if sub_type_name:
|
|
434
|
+
sub_type_name = PY_TO_JSON_TYPE.get(sub_type_name, sub_type_name)
|
|
435
|
+
if type_name not in SUPPORTED_TYPES or (
|
|
436
|
+
sub_type_name and sub_type_name not in SUPPORTED_TYPES
|
|
437
|
+
):
|
|
421
438
|
raise ValueError(
|
|
422
439
|
f"LLM 函数工具 {awaitable.__module__}_{llm_tool_name} 不支持的参数类型:{arg.type_name}",
|
|
423
440
|
)
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
441
|
+
|
|
442
|
+
arg_json_schema = {
|
|
443
|
+
"type": type_name,
|
|
444
|
+
"name": arg.arg_name,
|
|
445
|
+
"description": arg.description,
|
|
446
|
+
}
|
|
447
|
+
if sub_type_name:
|
|
448
|
+
if type_name == "array":
|
|
449
|
+
arg_json_schema["items"] = {"type": sub_type_name}
|
|
450
|
+
args.append(arg_json_schema)
|
|
451
|
+
|
|
432
452
|
if not registering_agent:
|
|
433
453
|
doc_desc = docstring.description.strip() if docstring.description else ""
|
|
434
454
|
md = get_handler_or_create(awaitable, EventType.OnCallingFuncToolEvent)
|
astrbot/dashboard/routes/chat.py
CHANGED
|
@@ -125,6 +125,8 @@ class ChatRoute(Route):
|
|
|
125
125
|
audio_url = post_data.get("audio_url")
|
|
126
126
|
selected_provider = post_data.get("selected_provider")
|
|
127
127
|
selected_model = post_data.get("selected_model")
|
|
128
|
+
enable_streaming = post_data.get("enable_streaming", True) # 默认为 True
|
|
129
|
+
|
|
128
130
|
if not message and not image_url and not audio_url:
|
|
129
131
|
return (
|
|
130
132
|
Response()
|
|
@@ -202,6 +204,8 @@ class ChatRoute(Route):
|
|
|
202
204
|
):
|
|
203
205
|
# 追加机器人消息
|
|
204
206
|
new_his = {"type": "bot", "message": result_text}
|
|
207
|
+
if "reasoning" in result:
|
|
208
|
+
new_his["reasoning"] = result["reasoning"]
|
|
205
209
|
await self.platform_history_mgr.insert(
|
|
206
210
|
platform_id="webchat",
|
|
207
211
|
user_id=webchat_conv_id,
|
|
@@ -224,6 +228,7 @@ class ChatRoute(Route):
|
|
|
224
228
|
"audio_url": audio_url,
|
|
225
229
|
"selected_provider": selected_provider,
|
|
226
230
|
"selected_model": selected_model,
|
|
231
|
+
"enable_streaming": enable_streaming,
|
|
227
232
|
},
|
|
228
233
|
),
|
|
229
234
|
)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: AstrBot
|
|
3
|
-
Version: 4.5.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 4.5.7
|
|
4
|
+
Summary: Easy-to-use multi-platform LLM chatbot and development framework
|
|
5
5
|
License-File: LICENSE
|
|
6
6
|
Keywords: Astrbot,Astrbot Module,Astrbot Plugin
|
|
7
7
|
Requires-Python: >=3.10
|
|
@@ -68,7 +68,7 @@ Description-Content-Type: text/markdown
|
|
|
68
68
|
|
|
69
69
|
<div>
|
|
70
70
|
<a href="https://trendshift.io/repositories/12875" target="_blank"><img src="https://trendshift.io/api/badge/repositories/12875" alt="Soulter%2FAstrBot | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
|
71
|
-
<a href="https://hellogithub.com/repository/AstrBotDevs/AstrBot" target="_blank"><img src="https://api.hellogithub.com/v1/widgets/recommend.svg?rid=d127d50cd5e54c5382328acc3bb25483&claim_uid=ZO9by7qCXgSd6Lp&t=
|
|
71
|
+
<a href="https://hellogithub.com/repository/AstrBotDevs/AstrBot" target="_blank"><img src="https://api.hellogithub.com/v1/widgets/recommend.svg?rid=d127d50cd5e54c5382328acc3bb25483&claim_uid=ZO9by7qCXgSd6Lp&t=2" alt="Featured|HelloGitHub" style="width: 250px; height: 54px;" width="250" height="54" /></a>
|
|
72
72
|
</div>
|
|
73
73
|
|
|
74
74
|
<br>
|
|
@@ -179,83 +179,73 @@ uv run main.py
|
|
|
179
179
|
|
|
180
180
|
<a href="https://discord.gg/hAVk6tgV36"><img alt="Discord_community" src="https://img.shields.io/badge/Discord-AstrBot-purple?style=for-the-badge&color=76bad9"></a>
|
|
181
181
|
|
|
182
|
-
##
|
|
182
|
+
## 支持的消息平台
|
|
183
183
|
|
|
184
184
|
**官方维护**
|
|
185
185
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
| Discord | ✔ |
|
|
199
|
-
| Satori | ✔ |
|
|
200
|
-
| Misskey | ✔ |
|
|
201
|
-
| Whatsapp | 将支持 |
|
|
202
|
-
| LINE | 将支持 |
|
|
186
|
+
- QQ (官方平台 & OneBot)
|
|
187
|
+
- Telegram
|
|
188
|
+
- 企微应用 & 企微智能机器人
|
|
189
|
+
- 微信客服 & 微信公众号
|
|
190
|
+
- 飞书
|
|
191
|
+
- 钉钉
|
|
192
|
+
- Slack
|
|
193
|
+
- Discord
|
|
194
|
+
- Satori
|
|
195
|
+
- Misskey
|
|
196
|
+
- Whatsapp (将支持)
|
|
197
|
+
- LINE (将支持)
|
|
203
198
|
|
|
204
199
|
**社区维护**
|
|
205
200
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
| [Bilibili 私信](https://github.com/Hina-Chat/astrbot_plugin_bilibili_adapter) | ✔ |
|
|
211
|
-
| [wxauto](https://github.com/luosheng520qaq/wxauto-repost-onebotv11) | ✔ |
|
|
201
|
+
- [KOOK](https://github.com/wuyan1003/astrbot_plugin_kook_adapter)
|
|
202
|
+
- [VoceChat](https://github.com/HikariFroya/astrbot_plugin_vocechat)
|
|
203
|
+
- [Bilibili 私信](https://github.com/Hina-Chat/astrbot_plugin_bilibili_adapter)
|
|
204
|
+
- [wxauto](https://github.com/luosheng520qaq/wxauto-repost-onebotv11)
|
|
212
205
|
|
|
213
|
-
##
|
|
206
|
+
## 支持的模型服务
|
|
214
207
|
|
|
215
208
|
**大模型服务**
|
|
216
209
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
210
|
+
- OpenAI 及兼容服务
|
|
211
|
+
- Anthropic
|
|
212
|
+
- Google Gemini
|
|
213
|
+
- Moonshot AI
|
|
214
|
+
- 智谱 AI
|
|
215
|
+
- DeepSeek
|
|
216
|
+
- Ollama (本地部署)
|
|
217
|
+
- LM Studio (本地部署)
|
|
218
|
+
- [优云智算](https://www.compshare.cn/?ytag=GPU_YY-gh_astrbot&referral_code=FV7DcGowN4hB5UuXKgpE74)
|
|
219
|
+
- [302.AI](https://share.302.ai/rr1M3l)
|
|
220
|
+
- [小马算力](https://www.tokenpony.cn/3YPyf)
|
|
221
|
+
- [硅基流动](https://docs.siliconflow.cn/cn/usercases/use-siliconcloud-in-astrbot)
|
|
222
|
+
- [PPIO 派欧云](https://ppio.com/user/register?invited_by=AIOONE)
|
|
223
|
+
- ModelScope
|
|
224
|
+
- OneAPI
|
|
225
|
+
|
|
226
|
+
**LLMOps 平台**
|
|
227
|
+
|
|
228
|
+
- Dify
|
|
229
|
+
- 阿里云百炼应用
|
|
230
|
+
- Coze
|
|
237
231
|
|
|
238
232
|
**语音转文本服务**
|
|
239
233
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
| Whisper | ✔ | 支持 API、本地部署 |
|
|
243
|
-
| SenseVoice | ✔ | 本地部署 |
|
|
234
|
+
- OpenAI Whisper
|
|
235
|
+
- SenseVoice
|
|
244
236
|
|
|
245
237
|
**文本转语音服务**
|
|
246
238
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
| Minimax TTS | ✔ | |
|
|
258
|
-
| 火山引擎 TTS | ✔ | |
|
|
239
|
+
- OpenAI TTS
|
|
240
|
+
- Gemini TTS
|
|
241
|
+
- GPT-Sovits-Inference
|
|
242
|
+
- GPT-Sovits
|
|
243
|
+
- FishAudio
|
|
244
|
+
- Edge TTS
|
|
245
|
+
- 阿里云百炼 TTS
|
|
246
|
+
- Azure TTS
|
|
247
|
+
- Minimax TTS
|
|
248
|
+
- 火山引擎 TTS
|
|
259
249
|
|
|
260
250
|
## ❤️ 贡献
|
|
261
251
|
|
|
@@ -289,7 +279,7 @@ pre-commit install
|
|
|
289
279
|
|
|
290
280
|
## ⭐ Star History
|
|
291
281
|
|
|
292
|
-
> [!TIP]
|
|
282
|
+
> [!TIP]
|
|
293
283
|
> 如果本项目对您的生活 / 工作产生了帮助,或者您关注本项目的未来发展,请给项目 Star,这是我们维护这个开源项目的动力 <3
|
|
294
284
|
|
|
295
285
|
<div align="center">
|