Refactor workflow routing and greeting management in Brain classes
- Update WorkflowBrain to handle greeting playback more effectively, ensuring that the initial greeting completes before transitioning to the first node. - Introduce new methods for managing greeting states and conditions, enhancing the interaction flow for user turns. - Refactor WorkflowLLMRouter to improve routing logic and ensure proper handling of conditional paths. - Enhance tests to verify the correct behavior of greeting management and routing under various scenarios, including waiting for audio playback to finish. - Update frontend components to reflect changes in edge handling and improve user experience in workflow configurations.
This commit is contained in:
@@ -27,11 +27,11 @@ import type { ExpressionRule, WorkflowEdgeData } from "../specs";
|
||||
|
||||
export function EdgeSettingsPanel({
|
||||
edge,
|
||||
sourceType,
|
||||
hasOtherDefaultPath,
|
||||
onChange,
|
||||
}: {
|
||||
edge: Edge;
|
||||
sourceType?: string;
|
||||
hasOtherDefaultPath: boolean;
|
||||
onChange: (patch: WorkflowEdgeData) => void;
|
||||
}) {
|
||||
const data = (edge.data ?? { mode: "always", priority: 10 }) as WorkflowEdgeData;
|
||||
@@ -100,15 +100,19 @@ export function EdgeSettingsPanel({
|
||||
<SectionCard
|
||||
icon={<GitBranch size={15} />}
|
||||
title="路由方式"
|
||||
description="选择由 Agent 判断、动态变量表达式判断,或作为确定性默认路径"
|
||||
description="每个节点最多一条默认路径,也可以配置多条条件路径"
|
||||
>
|
||||
<NodeSelect
|
||||
label="判断方式"
|
||||
label="条件类型"
|
||||
value={mode}
|
||||
options={[
|
||||
...(sourceType === "agent" ? [{ value: "llm", label: "LLM 判断" }] : []),
|
||||
{ value: "expression", label: "动态变量表达式" },
|
||||
{ value: "always", label: "默认路径" },
|
||||
{
|
||||
value: "always",
|
||||
label: "默认路径",
|
||||
disabled: mode !== "always" && hasOtherDefaultPath,
|
||||
},
|
||||
{ value: "llm", label: "大模型判断" },
|
||||
{ value: "expression", label: "表达式" },
|
||||
]}
|
||||
onChange={(value) => {
|
||||
const nextMode =
|
||||
@@ -118,6 +122,11 @@ export function EdgeSettingsPanel({
|
||||
}}
|
||||
allowNone={false}
|
||||
/>
|
||||
{mode !== "always" && hasOtherDefaultPath && (
|
||||
<span className="-mt-1 block text-xs text-muted-foreground">
|
||||
当前节点已经有一条默认路径;其它出边需要使用大模型判断或表达式。
|
||||
</span>
|
||||
)}
|
||||
<label className="block">
|
||||
<div className="mb-1.5 text-sm font-medium text-foreground">
|
||||
优先级
|
||||
@@ -133,7 +142,7 @@ export function EdgeSettingsPanel({
|
||||
className="border-hairline-strong bg-background text-foreground"
|
||||
/>
|
||||
<span className="mt-1.5 block text-xs text-muted-foreground">
|
||||
同一节点的边按数字从小到大依次判断。
|
||||
条件路径按数字从小到大判断,默认路径始终作为兜底。
|
||||
</span>
|
||||
</label>
|
||||
</SectionCard>
|
||||
@@ -333,5 +342,3 @@ export function EdgeSettingsPanel({
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -201,7 +201,11 @@ export function NodeSelect({
|
||||
<SelectContent className="border-hairline bg-popover text-popover-foreground">
|
||||
{allowNone && <SelectItem value={NONE}>{noneLabel}</SelectItem>}
|
||||
{options.map((option) => (
|
||||
<SelectItem key={option.value} value={option.value}>
|
||||
<SelectItem
|
||||
key={option.value}
|
||||
value={option.value}
|
||||
disabled={option.disabled}
|
||||
>
|
||||
{option.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
@@ -211,4 +215,3 @@ export function NodeSelect({
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user