Files
ai-video-fullstack/backend/services/brains/registry.py
Xin Wang 809b634420 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.
2026-06-16 16:55:51 +08:00

26 lines
905 B
Python

"""类型 → Brain 工厂。新增一种大脑 = 加一个 brain 文件 + 在此注册一行。"""
from __future__ import annotations
from models import AssistantConfig
from services.brains.base import Brain, BrainSpec
from services.brains.fastgpt_brain import FastGPTBrain
from services.brains.internal_brain import InternalBrain
# 各类型的元数据(供 schema 校验 / realtime 门控复用,无需实例化 Brain)。
SPECS: dict[str, BrainSpec] = {
"prompt": InternalBrain("prompt").spec,
"workflow": InternalBrain("workflow").spec,
"fastgpt": FastGPTBrain().spec,
}
def build_brain(cfg: AssistantConfig) -> Brain:
"""按 cfg.type 构造每通电话的 Brain 实例(未知类型回退 prompt)。"""
if cfg.type == "fastgpt":
return FastGPTBrain()
if cfg.type in ("prompt", "workflow"):
return InternalBrain(cfg.type)
return InternalBrain("prompt")