Refactor workflow agent and routing components for improved functionality
- Introduce WorkflowAgentStage to manage agent stage configurations and enhance interaction with the workflow engine. - Implement WorkflowEdgeEvaluator for priority-aware edge evaluation, improving routing decisions based on conditions and user turns. - Update WorkflowBrain to handle user turns and routing more effectively, ensuring agents cannot have only one default path. - Enhance CallEndCoordinator to track speech events and manage call termination based on queued speech. - Add new models and output handling for workflow interactions, improving clarity and maintainability. - Update tests to validate the new routing logic and agent behavior under various scenarios.
This commit is contained in:
@@ -27,10 +27,14 @@ import type { ExpressionRule, WorkflowEdgeData } from "../specs";
|
||||
|
||||
export function EdgeSettingsPanel({
|
||||
edge,
|
||||
sourceType,
|
||||
isOnlyOutgoing,
|
||||
hasOtherDefaultPath,
|
||||
onChange,
|
||||
}: {
|
||||
edge: Edge;
|
||||
sourceType?: string;
|
||||
isOnlyOutgoing: boolean;
|
||||
hasOtherDefaultPath: boolean;
|
||||
onChange: (patch: WorkflowEdgeData) => void;
|
||||
}) {
|
||||
@@ -109,7 +113,10 @@ export function EdgeSettingsPanel({
|
||||
{
|
||||
value: "always",
|
||||
label: "默认路径",
|
||||
disabled: mode !== "always" && hasOtherDefaultPath,
|
||||
disabled:
|
||||
mode !== "always" &&
|
||||
(hasOtherDefaultPath ||
|
||||
(sourceType === "agent" && isOnlyOutgoing)),
|
||||
},
|
||||
{ value: "llm", label: "大模型判断" },
|
||||
{ value: "expression", label: "表达式" },
|
||||
@@ -127,24 +134,31 @@ export function EdgeSettingsPanel({
|
||||
当前节点已经有一条默认路径;其它出边需要使用大模型判断或表达式。
|
||||
</span>
|
||||
)}
|
||||
<label className="block">
|
||||
<div className="mb-1.5 text-sm font-medium text-foreground">
|
||||
优先级
|
||||
</div>
|
||||
<Input
|
||||
type="number"
|
||||
value={priority}
|
||||
onChange={(event) => {
|
||||
const nextPriority = Number(event.target.value) || 0;
|
||||
setPriority(nextPriority);
|
||||
publish({ nextPriority });
|
||||
}}
|
||||
className="border-hairline-strong bg-background text-foreground"
|
||||
/>
|
||||
<span className="mt-1.5 block text-xs text-muted-foreground">
|
||||
条件路径按数字从小到大判断,默认路径始终作为兜底。
|
||||
{sourceType === "agent" && isOnlyOutgoing && mode === "always" && (
|
||||
<span className="-mt-1 block text-xs text-destructive">
|
||||
Agent 不能只有默认路径;请改为条件路径,或删除连接以持续对话。
|
||||
</span>
|
||||
</label>
|
||||
)}
|
||||
{mode !== "always" && (
|
||||
<label className="block">
|
||||
<div className="mb-1.5 text-sm font-medium text-foreground">
|
||||
优先级
|
||||
</div>
|
||||
<Input
|
||||
type="number"
|
||||
value={priority}
|
||||
onChange={(event) => {
|
||||
const nextPriority = Number(event.target.value) || 0;
|
||||
setPriority(nextPriority);
|
||||
publish({ nextPriority });
|
||||
}}
|
||||
className="border-hairline-strong bg-background text-foreground"
|
||||
/>
|
||||
<span className="mt-1.5 block text-xs text-muted-foreground">
|
||||
条件路径按数字从小到大判断;默认路径不参与优先级。
|
||||
</span>
|
||||
</label>
|
||||
)}
|
||||
</SectionCard>
|
||||
|
||||
<SectionCard
|
||||
|
||||
Reference in New Issue
Block a user