( command: string, calledActions: CalledAction[], varNames: string[], orgInfo: Pick<Organization, "name" | "description">, )
| 11 | } |
| 12 | |
| 13 | export 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 | |
| 42 | FACTS: |
| 43 | 1. Today's date is ${new Date().toISOString().split("T")[0]} |
| 44 | 2. Below are Typescript input and output types of the functions called: |
| 45 | |
| 46 | \`\`\` |
| 47 | ${actionTS} |
| 48 | \`\`\` |
| 49 | |
| 50 | RULES: |
| 51 | 1. DO NOT call the functions above and DO NOT redefine them |
| 52 | 2. 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 |
| 53 | 3. If the user's request is impossible given the data in the variables, raise an error: |
| 54 | \`\`\` |
| 55 | throw new Error("To visualize this graph, I need you to provide me with ..."); |
| 56 | \`\`\` |
| 57 | 4. 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() |
| 58 | 5. The user has code that visualizes the variable \`graphData\` which YOU MUST DEFINE as the following type: |
| 59 | \`\`\` |
| 60 | interface GraphData { |
| 61 | graphTitle: string |
| 62 | type: "line"|"bar"|"value" |
| 63 | data: {x:number|string;y:number}[] // If type is "value", then have a length 1 array and set y to the value |
| 64 | xLabel?: string |
| 65 | yLabel?: string // Include unit in brackets. Example: Conversion rate (%) |
| 66 | } |
| 67 | \`\`\` |
| 68 | 6. Do not include TS types in your code |
| 69 | 7. Unless ABSOLUTELY NECESSARY, do not perform string comparisons with hardcoded strings |
| 70 | 8. Respond in the format below. THIS IS VERY IMPORTANT. DO NOT FORGET THIS. Both 'Thoughts' and 'Code' are required sections: |
no test coverage detected