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

Function getDataAnalysisPrompt

lib/prompts/dataAnalysis.ts:13–87  ·  view source on GitHub ↗
(
  command: string,
  calledActions: CalledAction[],
  varNames: string[],
  orgInfo: Pick<Organization, "name" | "description">,
)

Source from the content-addressed store, hash-verified

11}
12
13export function getDataAnalysisPrompt(
14 command: string,
15 calledActions: CalledAction[],
16 varNames: string[],
17 orgInfo: Pick<Organization, "name" | "description">,
18): ChatGPTMessage[] {
19 const actionTS = calledActions
20 // Filter out duplicate actions from TS
21 .filter(
22 (a, idx) =>
23 idx ===
24 calledActions.findIndex(
25 (called) => called.action.name === a.action.name,
26 ),
27 )
28 .map((action) => {
29 return getActionTSSignature(action.action, true, action.output);
30 })
31 .join("\n");
32
33 return [
34 {
35 role: "system",
36 content: `${getIntroText(
37 orgInfo,
38 )} Your task is to help the user by writing Javascript to format data received from ${
39 orgInfo.name || "the API"
40 } which can then be visualized to answer the user's question.
41
42FACTS:
431. Today's date is ${new Date().toISOString().split("T")[0]}
442. Below are Typescript input and output types of the functions called:
45
46\`\`\`
47${actionTS}
48\`\`\`
49
50RULES:
511. DO NOT call the functions above and DO NOT redefine them
522. DO NOT redefine the variables defined in code in the user's message. USE THESE as the raw data to transform into a graph for the user
533. If the user's request is impossible given the data in the variables, raise an error:
54\`\`\`
55throw new Error("To visualize this graph, I need you to provide me with ...");
56\`\`\`
574. DO NOT import other libraries or frameworks and the following will cause runtime errors: fetch() (or any code that calls another server), eval(), new Function(), WebAssembly, console.log()
585. The user has code that visualizes the variable \`graphData\` which YOU MUST DEFINE as the following type:
59\`\`\`
60interface GraphData {
61graphTitle: string
62type: "line"|"bar"|"value"
63data: {x:number|string;y:number}[] // If type is "value", then have a length 1 array and set y to the value
64xLabel?: string
65yLabel?: string // Include unit in brackets. Example: Conversion rate (%)
66}
67\`\`\`
686. Do not include TS types in your code
697. Unless ABSOLUTELY NECESSARY, do not perform string comparisons with hardcoded strings
708. Respond in the format below. THIS IS VERY IMPORTANT. DO NOT FORGET THIS. Both 'Thoughts' and 'Code' are required sections:

Callers 2

runDataAnalysisFunction · 0.90

Calls 3

getActionTSSignatureFunction · 0.90
getIntroTextFunction · 0.90
getFunctionCallCodeFunction · 0.85

Tested by

no test coverage detected