Enhance conversation history and runtime variable management
- Update ConversationRecorder to include source and nodeId metadata in transcripts for better context tracking. - Introduce optional variable handling in DynamicVariableStore, allowing for unset variables to be rendered as empty without raising errors. - Refactor WorkflowBrain to apply turn configurations and manage interaction policies dynamically, improving agent responsiveness. - Implement tests to ensure proper handling of updated session variables and workflow metadata in various scenarios.
This commit is contained in:
@@ -23,6 +23,8 @@ class AgentStageConfig:
|
||||
knowledge_mode: str
|
||||
knowledge_top_n: int
|
||||
knowledge_score_threshold: float
|
||||
enable_interrupt: bool
|
||||
turn_config: dict[str, Any]
|
||||
|
||||
|
||||
class WorkflowEngine:
|
||||
@@ -106,6 +108,12 @@ class WorkflowEngine:
|
||||
asr_key = "defaultAsrResourceId" if inherits_global else "asrResourceId"
|
||||
tts_key = "defaultTtsResourceId" if inherits_global else "ttsResourceId"
|
||||
knowledge_base_id = str(source.get("knowledgeBaseId") or "")
|
||||
global_turn_config = self.settings.get("turnConfig")
|
||||
if not isinstance(global_turn_config, dict):
|
||||
global_turn_config = {}
|
||||
turn_config = source.get("turnConfig", global_turn_config)
|
||||
if not isinstance(turn_config, dict):
|
||||
turn_config = global_turn_config
|
||||
return AgentStageConfig(
|
||||
inherits_global=inherits_global,
|
||||
llm_resource_id=str(source.get(llm_key) or ""),
|
||||
@@ -122,6 +130,13 @@ class WorkflowEngine:
|
||||
knowledge_score_threshold=float(
|
||||
source.get("knowledgeScoreThreshold") or 0.0
|
||||
),
|
||||
enable_interrupt=bool(
|
||||
source.get(
|
||||
"enableInterrupt",
|
||||
self.settings.get("enableInterrupt", True),
|
||||
)
|
||||
),
|
||||
turn_config=dict(turn_config),
|
||||
)
|
||||
|
||||
def prompt_for(self, node_id: str, store: DynamicVariableStore) -> str:
|
||||
|
||||
Reference in New Issue
Block a user