* feat: 修改tool_loop_agent_runner,新增stream_to_general属性。 Co-authored-by: aider (openai/gemini-2.5-flash-preview) <aider@aider.chat> * refactor: 优化text_chat_stream,直接yield完整信息 Co-authored-by: aider (openai/gemini-2.5-flash-preview) <aider@aider.chat> * feat(core): ✨ 添加streaming_fallback选项,允许进行流式请求和非流式输出 添加了streaming_fallback配置,默认为false。在PlatformMetadata中新增字段用于标识是否支持真流式输出。在LLMRequest中添加判断是否启用Fallback。 #3431 #2793 #3014 * refactor(core): 将stream_to_general移出toolLoopAgentRunner * refactor(core.platform): 修改metadata中的属性名称 * fix: update streaming provider settings descriptions and add conditions * fix: update streaming configuration to use unsupported_streaming_strategy and adjust related logic * fix: remove support_streaming_message flag from WecomAIBotAdapter registration * fix: update hint for non-streaming platform handling in configuration * fix(core.pipeline): Update astrbot/core/pipeline/process_stage/method/llm_request.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix(core.pipeline): Update astrbot/core/pipeline/process_stage/method/llm_request.py --------- Co-authored-by: aider (openai/gemini-2.5-flash-preview) <aider@aider.chat> Co-authored-by: Soulter <37870767+Soulter@users.noreply.github.com> Co-authored-by: Soulter <905617992@qq.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
54 lines
1.9 KiB
Python
54 lines
1.9 KiB
Python
from astrbot.core import logger
|
|
|
|
from .platform_metadata import PlatformMetadata
|
|
|
|
platform_registry: list[PlatformMetadata] = []
|
|
"""维护了通过装饰器注册的平台适配器"""
|
|
platform_cls_map: dict[str, type] = {}
|
|
"""维护了平台适配器名称和适配器类的映射"""
|
|
|
|
|
|
def register_platform_adapter(
|
|
adapter_name: str,
|
|
desc: str,
|
|
default_config_tmpl: dict | None = None,
|
|
adapter_display_name: str | None = None,
|
|
logo_path: str | None = None,
|
|
support_streaming_message: bool = True,
|
|
):
|
|
"""用于注册平台适配器的带参装饰器。
|
|
|
|
default_config_tmpl 指定了平台适配器的默认配置模板。用户填写好后将会作为 platform_config 传入你的 Platform 类的实现类。
|
|
logo_path 指定了平台适配器的 logo 文件路径,是相对于插件目录的路径。
|
|
"""
|
|
|
|
def decorator(cls):
|
|
if adapter_name in platform_cls_map:
|
|
raise ValueError(
|
|
f"平台适配器 {adapter_name} 已经注册过了,可能发生了适配器命名冲突。",
|
|
)
|
|
|
|
# 添加必备选项
|
|
if default_config_tmpl:
|
|
if "type" not in default_config_tmpl:
|
|
default_config_tmpl["type"] = adapter_name
|
|
if "enable" not in default_config_tmpl:
|
|
default_config_tmpl["enable"] = False
|
|
if "id" not in default_config_tmpl:
|
|
default_config_tmpl["id"] = adapter_name
|
|
|
|
pm = PlatformMetadata(
|
|
name=adapter_name,
|
|
description=desc,
|
|
default_config_tmpl=default_config_tmpl,
|
|
adapter_display_name=adapter_display_name,
|
|
logo_path=logo_path,
|
|
support_streaming_message=support_streaming_message,
|
|
)
|
|
platform_registry.append(pm)
|
|
platform_cls_map[adapter_name] = cls
|
|
logger.debug(f"平台适配器 {adapter_name} 已注册")
|
|
return cls
|
|
|
|
return decorator
|