MCPcopy Create free account
hub / github.com/Superflows-AI/superflows / parseActionFilteringOutput

Function parseActionFilteringOutput

lib/v2/prompts/actionFiltering.ts:59–83  ·  view source on GitHub ↗
(
  output: string,
  possibleOutputs: string[],
)

Source from the content-addressed store, hash-verified

57 selectedFunctions: string[];
58}
59export function parseActionFilteringOutput(
60 output: string,
61 possibleOutputs: string[],
62): ActionFilteringOutput {
63 // Split out into thoughts and selected functions
64 if (!output.includes("Selected functions:")) {
65 return { thoughts: "", selectedFunctions: [] };
66 }
67 const thoughts = output.split("Selected functions:")[0].split("Thoughts:")[1];
68 return {
69 thoughts: thoughts ? thoughts.trim() : "",
70 selectedFunctions: output
71 .split("Selected functions:")[1]
72 .trim()
73 .split("\n")
74 .filter((s) => s.trim() !== "")
75 .map((s) => {
76 const match = s.match(/^(\d. |- )?([\w_]+).*\s?.*$/);
77 if (!match) return "";
78 return match[2];
79 })
80 .filter(Boolean)
81 .filter((s) => possibleOutputs.includes(s)),
82 };
83}

Callers 1

filterActionsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected