28 lines
925 B
Python
28 lines
925 B
Python
"""
|
||
backend/app/services/chat/executors/hybrid.py
|
||
|
||
用途:runtime_provider=hybrid 的聊天 Executor(强制 Handler + Dify 流)。
|
||
依赖:DifyChatExecutor;Handler 校验与前置准备由 stream_chat_via_executor 统一完成。
|
||
逻辑:接收已准备上下文并委托 DifyChatExecutor.stream。
|
||
"""
|
||
|
||
from __future__ import annotations
|
||
|
||
from typing import Iterator
|
||
|
||
from app.services.chat.executors.base import ChatExecutor, ChatStreamContext
|
||
from app.services.chat.executors.dify_chat import DifyChatExecutor
|
||
|
||
|
||
class HybridChatExecutor(ChatExecutor):
|
||
"""Hybrid:业务 Handler 前置 + Dify Chatflow 流。"""
|
||
|
||
provider_key = 'hybrid'
|
||
|
||
def __init__(self) -> None:
|
||
self._dify = DifyChatExecutor()
|
||
|
||
def stream(self, ctx: ChatStreamContext) -> Iterator[str]:
|
||
"""把已完成 Handler 准备的 Hybrid 上下文委托给 Dify Chatflow。"""
|
||
yield from self._dify.stream(ctx)
|