refactor: remove legacy assistant compatibility
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"""FastGPT 大脑:外部托管,context/KB/tools 全在 FastGPT 服务端。
|
||||
|
||||
cascade-only(realtime 不兼容外部大脑)。每通电话持有一个稳定 chatId:
|
||||
Pipeline-only(外部大脑不支持 Realtime)。每通电话持有一个稳定 chatId:
|
||||
greeting(get_chat_init)与后续每轮推理共用它,保证服务端上下文连续。
|
||||
"""
|
||||
|
||||
|
||||
@@ -364,31 +364,14 @@ class PromptBrain(BaseBrain):
|
||||
)
|
||||
|
||||
def _opening_message(self) -> dict[str, Any] | None:
|
||||
startup = self._cfg.startup if isinstance(self._cfg.startup, dict) else {}
|
||||
value = startup.get("opening_message", startup.get("openingMessage"))
|
||||
value = self._cfg.startup["opening_message"]
|
||||
return value if isinstance(value, dict) else None
|
||||
|
||||
def _opening_mode(self) -> str:
|
||||
startup = self._cfg.startup if isinstance(self._cfg.startup, dict) else {}
|
||||
value = str(startup.get("opening_mode", startup.get("openingMode")) or "")
|
||||
if value in {"interruptible", "playback", "confirmation"}:
|
||||
return value
|
||||
# Before openingMode existed, an opening message meant confirmation;
|
||||
# ordinary Prompt greetings were interruptible.
|
||||
return (
|
||||
"confirmation"
|
||||
if self._opening_message() is not None
|
||||
else "interruptible"
|
||||
)
|
||||
return str(self._cfg.startup["opening_mode"])
|
||||
|
||||
def _entry_mode(self) -> str:
|
||||
startup = self._cfg.startup if isinstance(self._cfg.startup, dict) else {}
|
||||
value = str(startup.get("entry_mode", startup.get("entryMode")) or "")
|
||||
if value in {"wait_user", "generate"}:
|
||||
return value
|
||||
# Raw runtime configs saved before entryMode existed generated a first
|
||||
# reply after their opening confirmation. Keep that legacy behavior.
|
||||
return "generate" if self._opening_mode() == "confirmation" else "wait_user"
|
||||
return str(self._cfg.startup["entry_mode"])
|
||||
|
||||
async def _enter_prompt_if_ready(self) -> None:
|
||||
if (
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Pipecat Flows-backed Workflow v3 brain."""
|
||||
"""Pipecat Flows-backed Workflow v4 brain."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -48,10 +48,8 @@ from services.action_stage import ActionStageRunner, ActionStageSpec, StageActio
|
||||
from services.fixed_speech import fixed_speech_context_message
|
||||
from services.knowledge import search as search_knowledge
|
||||
from services.message_policy import (
|
||||
MESSAGE_COMPLETION_POLICIES,
|
||||
MESSAGE_CONFIRMATION,
|
||||
MESSAGE_INTERRUPTIBLE,
|
||||
MESSAGE_PLAYBACK,
|
||||
)
|
||||
from services.message_stage import (
|
||||
MessageDisplaySpec,
|
||||
@@ -160,12 +158,6 @@ class WorkflowBrain(BaseBrain):
|
||||
def __init__(self, cfg_or_graph: AssistantConfig | dict[str, Any]):
|
||||
cfg = cfg_or_graph if isinstance(cfg_or_graph, AssistantConfig) else None
|
||||
graph = deepcopy(cfg.graph if cfg is not None else cfg_or_graph)
|
||||
if cfg is not None:
|
||||
# Graph v3 owns Workflow defaults. Keep older saved graphs compatible
|
||||
# by filling the new interaction settings from the assistant row.
|
||||
settings = graph.setdefault("settings", {})
|
||||
settings.setdefault("enableInterrupt", cfg.enableInterrupt)
|
||||
settings.setdefault("turnConfig", deepcopy(cfg.turnConfig))
|
||||
self._engine = WorkflowEngine(graph or {})
|
||||
if not self._engine.has_graph() or not self._engine.start_id:
|
||||
raise ValueError("WorkflowBrain 缺少有效的 Start 节点")
|
||||
@@ -722,7 +714,7 @@ class WorkflowBrain(BaseBrain):
|
||||
def _agent_runs_on_entry(self, node_id: str) -> bool:
|
||||
"""Only explicit generate mode may start a reply on node entry."""
|
||||
entry_mode = str(
|
||||
self._engine.data(node_id).get("entryMode") or "wait_user"
|
||||
self._engine.data(node_id).get("entryMode", "wait_user")
|
||||
)
|
||||
return entry_mode == "generate"
|
||||
|
||||
@@ -1604,21 +1596,17 @@ class WorkflowBrain(BaseBrain):
|
||||
return result
|
||||
|
||||
def _message_completion_policy(self, node_id: str) -> str:
|
||||
value = str(
|
||||
self._engine.data(node_id).get("completionPolicy")
|
||||
or MESSAGE_PLAYBACK
|
||||
)
|
||||
return value if value in MESSAGE_COMPLETION_POLICIES else MESSAGE_PLAYBACK
|
||||
return str(self._engine.data(node_id)["completionPolicy"])
|
||||
|
||||
def _set_last_action(self, outcome: ActionOutcome) -> None:
|
||||
legacy_status = {
|
||||
status_value = {
|
||||
ActionStatus.SUCCESS: "ok",
|
||||
ActionStatus.FAILURE: "error",
|
||||
ActionStatus.CANCELLED: "cancelled",
|
||||
}[outcome.status]
|
||||
self._store.values.update(
|
||||
{
|
||||
"system__last_action_status": legacy_status,
|
||||
"system__last_action_status": status_value,
|
||||
"system__last_action_invocation_id": outcome.invocation_id,
|
||||
"system__last_action_duration_ms": outcome.duration_ms,
|
||||
"system__last_action_error_code": (
|
||||
|
||||
Reference in New Issue
Block a user