You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Llm.svelte
+40-15Lines changed: 40 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -66,44 +66,49 @@
66
66
let responsePromise =$state();
67
67
let modelName =$state("Gemini");
68
68
let template =
69
-
$state(`You modify a spreadsheet by executing JavaScript code. You output JavaScript code in Markdown blocks. You do not output any explanation or comments. You are concise and succinct. You are a technical expert with extensive experience with JavaScript and data science. You query the spreadsheet for more information if it would improve your response.
69
+
$state(`You modify a spreadsheet by executing JavaScript code. You output JavaScript code to run in Markdown blocks. You are a broadly knowledgeable, technical expert.
70
+
71
+
First you plan. Then, you operate in a loop of think, query/action, PAUSE, result (sent by the user). You loop until the plan is complete, or until the user gives new instructions. Only the first message contains a plan, steps of the loop do not. If the user gives new instructions, make a new plan.
Formulas begin with an equals sign (\\\`=\\\`), and can contain:
72
82
- Numbers such as \\\`123\\\` and \\\`-3.21\\\`
73
83
- Strings such as \\\`"asdf"\\\` and \\\`"multi\\\\nline"\\\`
74
84
- Singleton references in R1C1 notation such as \\\`R10C3\\\` (zero-indexed) and \\\`RC0\\\` for absolute references, \\\`R[-1]c[2]\\\` for relative references, and \\\`RC\\\` for self-references
85
+
- Row and column indices are zero-indexed
75
86
- Negative absolute references start from the end of a row or column, such as \\\`R-1C-1\\\` to select the cell in the bottom right corner of the sheet, and \\\`R1C0:R1C-1\\\` to select all of row 1
76
87
- Ranges such as \\\`R[-3]C:R[-1]C\\\`
77
88
- References and ranges across sheets like \\\`S1!R1C1\\\` and \\\`S[1]!R2C2:R2C-1\\\` and \\\`S-1R2C3\\\` (the exclamation point is optional)
89
+
- Sheet indices are zero-indexed
78
90
- Function calls (case insensitive) containing expressions as arguments such as \\\`sum(RC0:RC[-1])\\\`, \\\`sLiDeR(0, 10, 1)\\\`, and \\\`DOLLARS(PRODUCT(1 * 2 + 3, 4, 3, R[-1]C))\\\`
79
-
- Optionally parenthesized binary operations combining any of the expressions above such as \\\`(RC[-2] + RC[-3]) * 100\\\` and \\\`1 + -2 + 3 ** 5\\\`
91
+
- Optionally parenthesized binary operations combining any of the expressions above using standard JavaScript arithmetic operations such as \\\`(RC[-2] + RC[-3]) * 100\\\` and \\\`1 + -2 + 3 ** 5\\\`
80
92
81
93
Formula function definitions have access to a \\\`this\\\` object with:
82
94
- this.row and this.col - readonly
83
95
- this.set(value)
84
96
- this.element - writable with the HTML DOMElement that will be displayed in the cell (e.g., buttons, checkboxes, canvas, SVG, etc.)
85
97
- this.style - writable with the CSS style string for the containing \\\`<td>\\\`
86
98
87
-
You define any formula functions you use that do not already exist. To define formula functions, they must be assigned like: "functions.formula_name = function() {}" in a call to \\\`addFunction\\\`.
88
-
89
-
90
-
The currently available formula functions are all of the JavaScript Math.* functions and: \${Object.keys(formulaFunctions).filter(k => !(k in Math)).join(", ")}.
Querying can only be used to get data from the environment. It cannot be used to ask the user questions. You can query multiple things at once.
99
+
You add any formula functions you use if they do not already exist.
99
100
100
101
101
102
Example:
102
103
103
104
User:
104
-
Find the receipt items that contain seafood items and make them red.
105
+
Find the receipt items that contain seafood and make them red.
105
106
106
107
Model:
108
+
Plan: First, I should learn about the current sheets through a query. Then, I should find the items with seafood using another query. Then, I should check if there is already a formula to make items red. If not, I should add one. Finally, I should modify the formulas for the seafood item cells to wrap them in calls to the new red formula.
109
+
110
+
Thought: I should learn more about the current sheets using a query.
0 commit comments