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

Function getVarNames

lib/prompts/dataAnalysis.ts:139–170  ·  view source on GitHub ↗
(calledActions: CalledAction[])

Source from the content-addressed store, hash-verified

137}
138
139export function getVarNames(calledActions: CalledAction[]): string[] {
140 const varNames: string[] = [];
141 for (const action of calledActions) {
142 console.log("action", action.action);
143 const funcName = snakeToCamel(action.action?.name);
144 // If function name unique, add that and move on
145 const baseAttempt = funcName + "Output";
146 if (!varNames.includes(baseAttempt)) {
147 varNames.push(baseAttempt);
148 continue;
149 }
150 // Replace 'Output' with something that refers to the parameters used to call it
151 const idxOf = varNames.indexOf(funcName + "Output");
152 // Compare args
153 let newName = "";
154 const otherArgs = calledActions[idxOf].args;
155 for (const [key, value] of Object.entries(action.args)) {
156 if (!(key in otherArgs) || otherArgs[key] !== value) {
157 newName = funcName + formatValueForVarName(key, value);
158 // Add a number at the end if not unique
159 if (newName in varNames) {
160 let i = 1;
161 while (varNames.includes(newName + i)) i++;
162 newName = newName + i;
163 }
164 break;
165 }
166 }
167 varNames.push(newName);
168 }
169 return varNames;
170}

Callers 2

runDataAnalysisFunction · 0.90

Calls 2

snakeToCamelFunction · 0.90
formatValueForVarNameFunction · 0.85

Tested by

no test coverage detected