Files

32 lines
1.1 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
backend/app/services/chat/executors/builtin.py
用途:runtime_provider=builtin 的聊天 Executor。
依赖:agent_registry.resolver.resolve_handler。
逻辑:stream_chat_via_executor 已校验并准备 Handler;v1 未实现完整 builtin 流时显式报错。
"""
from __future__ import annotations
from typing import Iterator
from app.core.errors import AppError
from app.services.agent_registry.resolver import resolve_handler
from app.services.chat.executors.base import ChatExecutor, ChatStreamContext
class BuiltinChatExecutor(ChatExecutor):
"""纯内置运行时 Executor。"""
provider_key = 'builtin'
def stream(self, ctx: ChatStreamContext) -> Iterator[str]:
"""返回尚未实现的明确错误,并保留 Handler key 便于诊断。"""
handler = resolve_handler(ctx.agent)
raise AppError(
code='AGENT.BUILTIN_NOT_IMPLEMENTED',
message='runtime_provider=builtin 的聊天流尚未实现,请使用 hybrid 或 dify',
http_status=501,
details={'handler_key': handler.handler_key},
)