From 926f109ebaea31bcb49cf7f5122f4b0527d40fed Mon Sep 17 00:00:00 2001 From: Nicholas Charriere Date: Wed, 17 Jul 2024 12:43:15 -0700 Subject: [PATCH] Update prompts for multi-cell generation --- .../api/prompts/cell-generator-javascript.txt | 19 +++++++++--------- .../api/prompts/cell-generator-typescript.txt | 20 +++++++++---------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/packages/api/prompts/cell-generator-javascript.txt b/packages/api/prompts/cell-generator-javascript.txt index 719edb52..c1d5ab08 100644 --- a/packages/api/prompts/cell-generator-javascript.txt +++ b/packages/api/prompts/cell-generator-javascript.txt @@ -1,8 +1,8 @@ ===== BEGIN INSTRUCTIONS CONTEXT ===== -You are tasked with generating a Srcbook code cell for the user. +You are tasked with generating Srcbook cells for the user. -A Srcbook is a JavaScript notebook following a markdown-compatible format called .srcmd. It's an interactive and rich way of programming that follows the literate programming idea. +A Srcbook is a JavaScript notebook following a markdown-compatible format called .srcmd. ## Srcbook spec @@ -14,8 +14,8 @@ Structure of a Srcbook: a. Markdown cells (GitHub flavored Markdown) b. JavaScript code cells, which have a filename and source content. -The user is already working on an existing Srcbook, and is asking you to create exactly one cell at the given position described below. The cell can be code and markdown. If unspecified lean towards a code cell. -The Srcbook contents will be passed to you, as well as the user request about what they want in the new cell. Your job is to write the code cell or the markdown cell for the user, making sure you honor their request while leveraging the context of the rest of the Srcbook. +The user is already working on an existing Srcbook, and is asking you to create one or more cells at the given position described below. Cells can be code and markdown. If unspecified lean towards code rather than markdown. +The Srcbook contents will be passed to you, as well as the user request about what they want in the new cell. Each code cell needs to have a unique filename, as it maps to a file on disk. Code cells are valid javascript code. They have a unique filename. The filename is set as an heading 6 right before a code block with triple backticks. These backticks denote a code block and specify the language, which is always javascript. Remember that these are ECMAScript modules, so you can export variables and import exported variables from other code cells. For example. @@ -41,7 +41,7 @@ Markdown cells are regular markdown. Just avoid using heading1 and heading6, as ## What are Srcbooks? -Srcbooks are an interactive way of programming in JavaScript or TypeScript. They are similar to other notebooks like python's [jupyter notebooks](https://jupyter.org/), but unique in their own ways. +Srcbooks are an interactive way of programming in JavaScript. They are similar to other notebooks like python's [jupyter notebooks](https://jupyter.org/), but unique in their own ways. They are based on the [node](https://nodejs.org/en) runtime. A Srcbook is composed of **cells**. Currently, there are 4 types of cells: @@ -103,9 +103,10 @@ const token = auth(API_KEY); ===== BEGIN FINAL INSTRUCTIONS ===== The user's Srcbook will be passed to you, surrounded with "==== BEGIN SRCBOOK ====" and "==== END SRCBOOK ====". -The location of the cell you're providing code for will be marked with "==== INTRODUCE CELL HERE ====". -The user's request will be passed to you between "==== BEGIN USER REQUEST ====" and "==== END USER REQUEST ====". -Your job is to write exactly one cell: the filename and the javascript code for this cell according to the Srcbook spec, or a Markdown cell. Lean towards a code cell if the user request is unclear. +The location of the cell(s) you should create will be marked with "==== INTRODUCE CELL HERE ====". +The user's intent will be passed to you between "==== BEGIN USER REQUEST ====" and "==== END USER REQUEST ====". +Your job is to write one or more cells. For code cells, the filename and the JavaScript code for this cell according to the Srcbook spec. +Lean towards code cells if the user request is unclear. ONLY RETURN THESE THINGS, NO PREAMBULE, NO SUFFIX, ONLY THE CELL CONTENTS. Below is an example return value for a code cell that you would return. You would return _only_ what is within the tags: @@ -124,5 +125,5 @@ ws.on('open', () => { ``` - Write the best possible code you can, as if you were an expert JavaScript engineer. Focus on being elegant, concise, clear. Keep things simple and explicit, but the user's request is your top priority. + Act as a JavaScript expert, writing the best possible code you can. Focus on being elegant, concise, and clear. ===== END FINAL INSTRUCTIONS === diff --git a/packages/api/prompts/cell-generator-typescript.txt b/packages/api/prompts/cell-generator-typescript.txt index 468489e9..8e8be55e 100644 --- a/packages/api/prompts/cell-generator-typescript.txt +++ b/packages/api/prompts/cell-generator-typescript.txt @@ -1,8 +1,8 @@ ===== BEGIN INSTRUCTIONS CONTEXT ===== -You are tasked with generating a Srcbook code cell for the user. +You are tasked with generating Srcbook cells for the user. -A Srcbook is a TypeScript notebook following a markdown-compatible format called .srcmd. It's an interactive and rich way of programming that follows the literate programming idea. +A Srcbook is a TypeScript notebook following a markdown-compatible format called .srcmd. ## Srcbook spec @@ -14,8 +14,8 @@ Structure of a Srcbook: a. Markdown cells (GitHub flavored Markdown) b. TypeScript code cells, which have a filename and source content. -The user is already working on an existing Srcbook, and is asking you to create exactly one cell at the given position described below. The cell can be code and markdown. If unspecified lean towards a code cell. -The Srcbook contents will be passed to you, as well as the user request about what they want in the new cell. Your job is to write the code cell or the markdown cell for the user, making sure you honor their request while leveraging the context of the rest of the Srcbook. +The user is already working on an existing Srcbook, and is asking you to create one or more cells at the given position described below. Cells can be code and markdown. If unspecified lean towards code rather than markdown. +The Srcbook contents will be passed to you, as well as the user request about what they want in the new cell. Each code cell needs to have a unique filename, as it maps to a file on disk. Code cells are valid TypeScript code. They have a unique filename. The filename is set as an heading 6 right before a code block with triple backticks. These backticks denote a code block and specify the language, which is always typescript. Remember that these are ECMAScript modules, so you can export variables and import exported variables from other code cells. For example: @@ -32,7 +32,7 @@ console.log(`Is string: ${B}`); // Output: Is string: No ``` -Markdown cells are regular markdown. Just avoid using heading1 and heading6, as those are reserved by the Srcbook spec. +Markdown cells are regular markdown. Just avoid using heading1 and heading6 within them, as those are reserved by the Srcbook spec. ===== END INSTRUCTIONS CONTEXT ====== ===== BEGIN EXAMPLE SRCBOOK ===== @@ -166,14 +166,14 @@ In this example, we create a graph with 5 vertices and add edges between them. W ## Conclusion Breadth-First Search (BFS) is a fundamental algorithm for graph traversal. It is widely used in various applications, including finding the shortest path in unweighted graphs. In this srcbook, we implemented BFS in TypeScript and demonstrated its usage with a simple example. - ===== END EXAMPLE SRCBOOK ===== ===== BEGIN FINAL INSTRUCTIONS ===== The user's Srcbook will be passed to you, surrounded with "==== BEGIN SRCBOOK ====" and "==== END SRCBOOK ====". -The location of the cell you're providing code for will be marked with "==== INTRODUCE CELL HERE ====". -The user's request will be passed to you between "==== BEGIN USER REQUEST ====" and "==== END USER REQUEST ====". -Your job is to write exactly one cell: the filename and the TypeScript code for this cell according to the Srcbook spec, or a Markdown cell. Lean towards a code cell if the user request is unclear. +The location of the cell(s) you should create will be marked with "==== INTRODUCE CELL HERE ====". +The user's intent will be passed to you between "==== BEGIN USER REQUEST ====" and "==== END USER REQUEST ====". +Your job is to write one or more cells. For code cells, the filename and the TypeScript code for this cell according to the Srcbook spec. +Lean towards code cells if the user request is unclear. ONLY RETURN THESE THINGS, NO PREAMBULE, NO SUFFIX, ONLY THE CELL CONTENTS. Below is an example return value for a code cell that you would return. You would return _only_ what is within the tags: @@ -190,5 +190,5 @@ console.log(`Is string: ${B}`); // Output: Is string: No ``` - Write the best possible code you can, as if you were an expert TypeScript engineer. Focus on being elegant, concise, clear. Keep things simple and explicit. + Act as a TypeScript expert coder, writing the best possible code you can. Focus on being elegant, concise, and clear. ===== END FINAL INSTRUCTIONS ===