feat: add session updates and message dialogs
This commit is contained in:
@@ -28,7 +28,12 @@ from pipecat.services.llm_service import (
|
||||
FunctionCallParams,
|
||||
FunctionCallResultProperties,
|
||||
)
|
||||
from services.brains.base import BaseBrain, BrainRuntime, BrainSpec
|
||||
from services.brains.base import (
|
||||
BaseBrain,
|
||||
BrainRuntime,
|
||||
BrainSpec,
|
||||
SessionVariableUpdate,
|
||||
)
|
||||
from services.knowledge import search as search_knowledge
|
||||
from services.runtime_variables import DynamicVariableStore
|
||||
from services.tool_executor import ToolExecutionError, ToolExecutor
|
||||
@@ -258,6 +263,27 @@ class WorkflowBrain(BaseBrain):
|
||||
node_id=current_node,
|
||||
)
|
||||
|
||||
async def on_session_update(
|
||||
self,
|
||||
dynamic_variables: dict[str, Any],
|
||||
) -> SessionVariableUpdate:
|
||||
if self._ended:
|
||||
raise ValueError("工作流会话已经结束")
|
||||
changed = self._store.assign_declared_many(dynamic_variables)
|
||||
current = self._state.current_node_id
|
||||
if changed and current and self._engine.node_type(current) == "agent":
|
||||
await self._refresh_agent_prompt(current)
|
||||
if changed:
|
||||
await self._emit_variables(
|
||||
reason="session_update",
|
||||
node_id=current or None,
|
||||
changed=changed,
|
||||
)
|
||||
return SessionVariableUpdate(
|
||||
changed=changed,
|
||||
dynamic_variables=self._store.public_values(),
|
||||
)
|
||||
|
||||
def record_user_message(self, content: str) -> None:
|
||||
if content and not self._ended:
|
||||
self._store.record("user", content)
|
||||
|
||||
Reference in New Issue
Block a user