Enhance AssistantConfig and pipeline for FastGPT integration
- Add new fields in AssistantConfig for FastGPT connection details, including `fastgpt_api_url`, `fastgpt_api_key`, and `fastgpt_app_id`. - Update the pipeline to utilize the new FastGPT configuration, ensuring proper integration with external services. - Introduce type handling for different assistant types, including support for realtime modes and external brain management. - Refactor frontend components to include hints for FastGPT configuration inputs, improving user guidance during setup.
This commit is contained in:
37
backend/services/brains/internal_brain.py
Normal file
37
backend/services/brains/internal_brain.py
Normal file
@@ -0,0 +1,37 @@
|
||||
"""内部 LLM 大脑:prompt 与 workflow。
|
||||
|
||||
二者都用本地维护的 LLMContext + OpenAI 兼容 LLM,支持 cascade 与 realtime。
|
||||
workflow 的图编排(切提示/转移工具/node-active)阶段 1 仍内联在 pipeline.py,
|
||||
这里只负责提供 LLM 槽位与元数据,行为与改造前完全一致。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from models import AssistantConfig
|
||||
from pipecat.processors.aggregators.llm_context import LLMContext
|
||||
from pipecat.processors.frame_processor import FrameProcessor
|
||||
|
||||
from services.brains.base import BrainSpec
|
||||
|
||||
_CASCADE_AND_REALTIME = frozenset({"pipeline", "realtime"})
|
||||
|
||||
|
||||
class InternalBrain:
|
||||
"""prompt / workflow 共用。"""
|
||||
|
||||
def __init__(self, brain_type: str):
|
||||
self.spec = BrainSpec(
|
||||
type=brain_type,
|
||||
supported_runtime_modes=_CASCADE_AND_REALTIME,
|
||||
owns_context=True,
|
||||
)
|
||||
|
||||
async def greeting(self, cfg: AssistantConfig) -> str:
|
||||
# 内部类型的开场白由 pipeline.py 现有逻辑(workflow 起始节点 / cfg.greeting)决定,
|
||||
# 该方法仅为满足 Brain 协议,实际不在内部路径上被调用。
|
||||
return cfg.greeting
|
||||
|
||||
def build_llm(self, cfg: AssistantConfig, context: LLMContext) -> FrameProcessor:
|
||||
from services.pipecat.service_factory import create_llm
|
||||
|
||||
return create_llm(cfg)
|
||||
Reference in New Issue
Block a user