refactor: remove legacy assistant compatibility
This commit is contained in:
@@ -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