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

Function getFunctionCallCode

lib/prompts/dataAnalysis.ts:89–118  ·  view source on GitHub ↗
(
  calledActions: CalledAction[],
  varNames: string[],
)

Source from the content-addressed store, hash-verified

87}
88
89export function getFunctionCallCode(
90 calledActions: CalledAction[],
91 varNames: string[],
92): string {
93 // Write code to include in prior assistant message
94
95 return calledActions
96 .map((a, idx) => {
97 const funcName = snakeToCamel(a.action.name);
98 let argsText = Object.entries(a.args)
99 .map(([key, value]) => {
100 return `${key}:${JSON.stringify(value)}`;
101 })
102 .join(",");
103 let lengthStr = "";
104 if (a.output && Array.isArray(a.output)) {
105 lengthStr = `// Length: ${a.output.length}`;
106 } else if (
107 a.output &&
108 typeof a.output === "object" &&
109 "items" in a.output &&
110 Array.isArray(a.output.items)
111 ) {
112 lengthStr = `// ${varNames[idx]}.items.length = ${a.output.items.length}`;
113 }
114 argsText = argsText ? `{${argsText}}` : "";
115 return `const ${varNames[idx]} = ${funcName}(${argsText});${lengthStr}`;
116 })
117 .join("\n");
118}
119
120function formatValueForVarName(key: string, value: any): string {
121 if (Array.isArray(value)) {

Callers 1

getDataAnalysisPromptFunction · 0.85

Calls 1

snakeToCamelFunction · 0.90

Tested by

no test coverage detected