19 lines
947 B
TypeScript
19 lines
947 B
TypeScript
import type { AgentWorkflowOptionUiConfig, AgentWorkflowStepUiConfig } from "@/types/agent";
|
|
|
|
export function omitAgentWorkflowPrompts(steps: AgentWorkflowStepUiConfig[]): AgentWorkflowStepUiConfig[] {
|
|
const omitOptionPrompt = ({ promptFragment: _prompt, children, ...option }: AgentWorkflowOptionUiConfig): AgentWorkflowOptionUiConfig => ({
|
|
...option,
|
|
...(children?.length ? { children: children.map(omitOptionPrompt) } : {}),
|
|
});
|
|
return steps.map(({ options, children, ...step }) => ({
|
|
...step,
|
|
options: options.map(omitOptionPrompt),
|
|
...(children?.length ? { children: omitAgentWorkflowPrompts(children) } : {}),
|
|
}));
|
|
}
|
|
|
|
export function getWorkflowSelectionsRequest(selections: Record<string, string | undefined>) {
|
|
const entries = Object.entries(selections).filter(([, value]) => value?.trim());
|
|
return entries.length ? JSON.stringify(Object.fromEntries(entries.sort(([a], [b]) => a.localeCompare(b)))) : "";
|
|
}
|