From be18dbec92996dc2c3b1b15bdaf2bf269f9369cb Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 11 Oct 2024 13:39:54 +0000 Subject: [PATCH 1/4] =?UTF-8?q?=E2=9C=A8=20feat:=20Add=20meta=5Fprompt=20a?= =?UTF-8?q?nd=20meta=5Fschema=20tools?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/genaisrc/genaiscript.d.ts | 4 + docs/src/components/BuiltinTools.mdx | 2 + .../content/docs/reference/scripts/system.mdx | 409 +++++++++++++++++- eval/extrism/genaisrc/genaiscript.d.ts | 4 + genaisrc/genaiscript.d.ts | 4 + packages/auto/genaiscript.d.ts | 4 + .../copilot_chat_participant.genai.mjs | 1 - packages/core/src/genaisrc/genaiscript.d.ts | 4 + .../src/genaisrc/system.meta_prompt.genai.mjs | 73 ++++ .../src/genaisrc/system.meta_schema.genai.mjs | 309 +++++++++++++ packages/core/src/systems.ts | 4 +- .../sample/genaisrc/blog/genaiscript.d.ts | 4 + packages/sample/genaisrc/genaiscript.d.ts | 4 + .../sample/genaisrc/node/genaiscript.d.ts | 4 + .../sample/genaisrc/python/genaiscript.d.ts | 4 + .../sample/genaisrc/style/genaiscript.d.ts | 4 + packages/sample/src/aici/genaiscript.d.ts | 4 + packages/sample/src/errors/genaiscript.d.ts | 4 + packages/sample/src/genaiscript.d.ts | 4 + packages/sample/src/makecode/genaiscript.d.ts | 4 + packages/sample/src/tla/genaiscript.d.ts | 4 + packages/sample/src/vision/genaiscript.d.ts | 4 + packages/vscode/genaisrc/genaiscript.d.ts | 4 + slides/genaisrc/genaiscript.d.ts | 4 + 24 files changed, 866 insertions(+), 4 deletions(-) create mode 100644 packages/core/src/genaisrc/system.meta_prompt.genai.mjs create mode 100644 packages/core/src/genaisrc/system.meta_schema.genai.mjs diff --git a/docs/genaisrc/genaiscript.d.ts b/docs/genaisrc/genaiscript.d.ts index 6690e3ba8e..ba8452c376 100644 --- a/docs/genaisrc/genaiscript.d.ts +++ b/docs/genaisrc/genaiscript.d.ts @@ -99,6 +99,8 @@ type SystemPromptId = OptionsOrString< | "system.math" | "system.md_find_files" | "system.md_frontmatter" + | "system.meta_prompt" + | "system.meta_schema" | "system.node_info" | "system.node_test" | "system.planner" @@ -155,6 +157,8 @@ type SystemToolId = OptionsOrString< | "math_eval" | "md_find_files" | "md_read_frontmatter" + | "meta_prompt" + | "meta_schema" | "node_test" | "python_code_interpreter_copy_files" | "python_code_interpreter_run" diff --git a/docs/src/components/BuiltinTools.mdx b/docs/src/components/BuiltinTools.mdx index aa02b77944..0f963050d4 100644 --- a/docs/src/components/BuiltinTools.mdx +++ b/docs/src/components/BuiltinTools.mdx @@ -32,6 +32,8 @@ import { LinkCard } from '@astrojs/starlight/components'; + + diff --git a/docs/src/content/docs/reference/scripts/system.mdx b/docs/src/content/docs/reference/scripts/system.mdx index 20964209c9..e371caf46c 100644 --- a/docs/src/content/docs/reference/scripts/system.mdx +++ b/docs/src/content/docs/reference/scripts/system.mdx @@ -99,7 +99,6 @@ script({ "system.safety_harmful_content", ], tools: ["agent"], - excludedSystem: ["system.agent_user_input"], group: "infrastructure", parameters: { question: { @@ -1892,6 +1891,414 @@ defTool( ````` +### `system.meta_prompt` + +Tool that applies OpenAI's meta prompt guidelines to a user prompt + +Modified meta-prompt tool from https://platform.openai.com/docs/guides/prompt-generation?context=text-out. + +- tool `meta_prompt`: Tool that applies OpenAI's meta prompt guidelines to a user prompt. Modified from https://platform.openai.com/docs/guides/prompt-generation?context=text-out. + +`````js wrap title="system.meta_prompt" +system({ + title: "Tool that applies OpenAI's meta prompt guidelines to a user prompt", + description: + "Modified meta-prompt tool from https://platform.openai.com/docs/guides/prompt-generation?context=text-out.", +}) + +defTool( + "meta_prompt", + "Tool that applies OpenAI's meta prompt guidelines to a user prompt. Modified from https://platform.openai.com/docs/guides/prompt-generation?context=text-out.", + { + prompt: { + type: "string", + description: + "User prompt to be converted to a detailed system prompt using OpenAI's meta prompt guidelines", + }, + }, + async ({ prompt: userPrompt }) => { + const res = await runPrompt( + (_) => { + _.$`Given a task description or existing prompt in USER_PROMPT, produce a detailed system prompt to guide a language model in completing the task effectively. + +# Guidelines + +- Understand the Task: Grasp the main objective, goals, requirements, constraints, and expected output. +- Minimal Changes: If an existing prompt is provided, improve it only if it's simple. For complex prompts, enhance clarity and add missing elements without altering the original structure. +- Reasoning Before Conclusions**: Encourage reasoning steps before any conclusions are reached. ATTENTION! If the user provides examples where the reasoning happens afterward, REVERSE the order! NEVER START EXAMPLES WITH CONCLUSIONS! + - Reasoning Order: Call out reasoning portions of the prompt and conclusion parts (specific fields by name). For each, determine the ORDER in which this is done, and whether it needs to be reversed. + - Conclusion, classifications, or results should ALWAYS appear last. +- Examples: Include high-quality examples if helpful, using placeholders [in brackets] for complex elements. + - What kinds of examples may need to be included, how many, and whether they are complex enough to benefit from placeholders. +- Clarity and Conciseness: Use clear, specific language. Avoid unnecessary instructions or bland statements. +- Formatting: Use markdown features for readability. +- Preserve User Content: If the input task or prompt includes extensive guidelines or examples, preserve them entirely, or as closely as possible. If they are vague, consider breaking down into sub-steps. Keep any details, guidelines, examples, variables, or placeholders provided by the user. +- Constants: DO include constants in the prompt, as they are not susceptible to prompt injection. Such as guides, rubrics, and examples. +- Output Format: Explicitly the most appropriate output format, in detail. This should include length and syntax (e.g. short sentence, paragraph, YAML, INI, CSV, JSON, etc.) + - For tasks outputting well-defined or structured data (classification, JSON, etc.) bias toward outputting a YAML. + +The final prompt you output should adhere to the following structure below. Do not include any additional commentary, only output the completed system prompt. SPECIFICALLY, do not include any additional messages at the start or end of the prompt. (e.g. no "---") + +[Concise instruction describing the task - this should be the first line in the prompt, no section header] + +[Additional details as needed.] + +[Optional sections with headings or bullet points for detailed steps.] + +# Steps [optional] + +[optional: a detailed breakdown of the steps necessary to accomplish the task] + +# Output Format + +[Specifically call out how the output should be formatted, be it response length, structure e.g. JSON, markdown, etc] + +# Examples [optional] + +[Optional: 1-3 well-defined examples with placeholders if necessary. Clearly mark where examples start and end, and what the input and output are. User placeholders as necessary.] +[If the examples are shorter than what a realistic example is expected to be, make a reference with () explaining how real examples should be longer / shorter / different. AND USE PLACEHOLDERS! ] + +# Notes [optional] + +[optional: edge cases, details, and an area to call or repeat out specific important considerations]` + _.def("USER_PROMPT", userPrompt) + }, + { + model: "large", + label: "meta-prompt", + system: ["system.safety_jailbreak"], + } + ) + console.log(res.text ?? res.error) + return res + } +) + +````` + + +### `system.meta_schema` + +Tool that generate a valid schema for the described JSON + +OpenAI's meta schema generator from https://platform.openai.com/docs/guides/prompt-generation?context=structured-output-schema. + +- tool `meta_schema`: Generate a valid JSON schema for the described JSON. Source https://platform.openai.com/docs/guides/prompt-generation?context=structured-output-schema. + +`````js wrap title="system.meta_schema" +system({ + title: "Tool that generate a valid schema for the described JSON", + description: + "OpenAI's meta schema generator from https://platform.openai.com/docs/guides/prompt-generation?context=structured-output-schema.", +}) + +const metaSchema = Object.freeze({ + name: "metaschema", + schema: { + type: "object", + properties: { + name: { + type: "string", + description: "The name of the schema", + }, + type: { + type: "string", + enum: [ + "object", + "array", + "string", + "number", + "boolean", + "null", + ], + }, + properties: { + type: "object", + additionalProperties: { + $ref: "#/$defs/schema_definition", + }, + }, + items: { + anyOf: [ + { + $ref: "#/$defs/schema_definition", + }, + { + type: "array", + items: { + $ref: "#/$defs/schema_definition", + }, + }, + ], + }, + required: { + type: "array", + items: { + type: "string", + }, + }, + additionalProperties: { + type: "boolean", + }, + }, + required: ["type"], + additionalProperties: false, + if: { + properties: { + type: { + const: "object", + }, + }, + }, + then: { + required: ["properties"], + }, + $defs: { + schema_definition: { + type: "object", + properties: { + type: { + type: "string", + enum: [ + "object", + "array", + "string", + "number", + "boolean", + "null", + ], + }, + properties: { + type: "object", + additionalProperties: { + $ref: "#/$defs/schema_definition", + }, + }, + items: { + anyOf: [ + { + $ref: "#/$defs/schema_definition", + }, + { + type: "array", + items: { + $ref: "#/$defs/schema_definition", + }, + }, + ], + }, + required: { + type: "array", + items: { + type: "string", + }, + }, + additionalProperties: { + type: "boolean", + }, + }, + required: ["type"], + additionalProperties: false, + if: { + properties: { + type: { + const: "object", + }, + }, + }, + then: { + required: ["properties"], + }, + }, + }, + }, +}) + +defTool( + "meta_schema", + "Generate a valid JSON schema for the described JSON. Source https://platform.openai.com/docs/guides/prompt-generation?context=structured-output-schema.", + { + description: { + type: "string", + description: "Description of the JSON structure", + }, + }, + async ({ description }) => { + const res = await runPrompt( + (_) => { + _.$`# Instructions +Return a valid schema for the described JSON. + +You must also make sure: +- all fields in an object are set as required +- I REPEAT, ALL FIELDS MUST BE MARKED AS REQUIRED +- all objects must have additionalProperties set to false + - because of this, some cases like "attributes" or "metadata" properties that would normally allow additional properties should instead have a fixed set of properties +- all objects must have properties defined +- field order matters. any form of "thinking" or "explanation" should come before the conclusion +- $defs must be defined under the schema param + +Notable keywords NOT supported include: +- For strings: minLength, maxLength, pattern, format +- For numbers: minimum, maximum, multipleOf +- For objects: patternProperties, unevaluatedProperties, propertyNames, minProperties, maxProperties +- For arrays: unevaluatedItems, contains, minContains, maxContains, minItems, maxItems, uniqueItems + +Other notes: +- definitions and recursion are supported +- only if necessary to include references e.g. "$defs", it must be inside the "schema" object + +# Examples +Input: Generate a math reasoning schema with steps and a final answer. +Output: ${JSON.stringify({ + name: "math_reasoning", + type: "object", + properties: { + steps: { + type: "array", + description: + "A sequence of steps involved in solving the math problem.", + items: { + type: "object", + properties: { + explanation: { + type: "string", + description: + "Description of the reasoning or method used in this step.", + }, + output: { + type: "string", + description: + "Result or outcome of this specific step.", + }, + }, + required: ["explanation", "output"], + additionalProperties: false, + }, + }, + final_answer: { + type: "string", + description: + "The final solution or answer to the math problem.", + }, + }, + required: ["steps", "final_answer"], + additionalProperties: false, + })} + +Input: Give me a linked list +Output: ${JSON.stringify({ + name: "linked_list", + type: "object", + properties: { + linked_list: { + $ref: "#/$defs/linked_list_node", + description: "The head node of the linked list.", + }, + }, + $defs: { + linked_list_node: { + type: "object", + description: + "Defines a node in a singly linked list.", + properties: { + value: { + type: "number", + description: + "The value stored in this node.", + }, + next: { + anyOf: [ + { + $ref: "#/$defs/linked_list_node", + }, + { + type: "null", + }, + ], + description: + "Reference to the next node; null if it is the last node.", + }, + }, + required: ["value", "next"], + additionalProperties: false, + }, + }, + required: ["linked_list"], + additionalProperties: false, + })} + +Input: Dynamically generated UI +Output: ${JSON.stringify({ + name: "ui", + type: "object", + properties: { + type: { + type: "string", + description: "The type of the UI component", + enum: [ + "div", + "button", + "header", + "section", + "field", + "form", + ], + }, + label: { + type: "string", + description: + "The label of the UI component, used for buttons or form fields", + }, + children: { + type: "array", + description: "Nested UI components", + items: { + $ref: "#", + }, + }, + attributes: { + type: "array", + description: + "Arbitrary attributes for the UI component, suitable for any element", + items: { + type: "object", + properties: { + name: { + type: "string", + description: + "The name of the attribute, for example onClick or className", + }, + value: { + type: "string", + description: + "The value of the attribute", + }, + }, + required: ["name", "value"], + additionalProperties: false, + }, + }, + }, + required: ["type", "label", "children", "attributes"], + additionalProperties: false, + })}` + _.def("DESCRIPTION", description) + }, + { + model: "large", + responseSchema: metaSchema, + responseType: "json_schema", + system: ["system.safety_jailbreak"], + } + ) + return res + } +) + +````` + + ### `system.node_info` Information about the current project diff --git a/eval/extrism/genaisrc/genaiscript.d.ts b/eval/extrism/genaisrc/genaiscript.d.ts index 6690e3ba8e..ba8452c376 100644 --- a/eval/extrism/genaisrc/genaiscript.d.ts +++ b/eval/extrism/genaisrc/genaiscript.d.ts @@ -99,6 +99,8 @@ type SystemPromptId = OptionsOrString< | "system.math" | "system.md_find_files" | "system.md_frontmatter" + | "system.meta_prompt" + | "system.meta_schema" | "system.node_info" | "system.node_test" | "system.planner" @@ -155,6 +157,8 @@ type SystemToolId = OptionsOrString< | "math_eval" | "md_find_files" | "md_read_frontmatter" + | "meta_prompt" + | "meta_schema" | "node_test" | "python_code_interpreter_copy_files" | "python_code_interpreter_run" diff --git a/genaisrc/genaiscript.d.ts b/genaisrc/genaiscript.d.ts index 6690e3ba8e..ba8452c376 100644 --- a/genaisrc/genaiscript.d.ts +++ b/genaisrc/genaiscript.d.ts @@ -99,6 +99,8 @@ type SystemPromptId = OptionsOrString< | "system.math" | "system.md_find_files" | "system.md_frontmatter" + | "system.meta_prompt" + | "system.meta_schema" | "system.node_info" | "system.node_test" | "system.planner" @@ -155,6 +157,8 @@ type SystemToolId = OptionsOrString< | "math_eval" | "md_find_files" | "md_read_frontmatter" + | "meta_prompt" + | "meta_schema" | "node_test" | "python_code_interpreter_copy_files" | "python_code_interpreter_run" diff --git a/packages/auto/genaiscript.d.ts b/packages/auto/genaiscript.d.ts index 6690e3ba8e..ba8452c376 100644 --- a/packages/auto/genaiscript.d.ts +++ b/packages/auto/genaiscript.d.ts @@ -99,6 +99,8 @@ type SystemPromptId = OptionsOrString< | "system.math" | "system.md_find_files" | "system.md_frontmatter" + | "system.meta_prompt" + | "system.meta_schema" | "system.node_info" | "system.node_test" | "system.planner" @@ -155,6 +157,8 @@ type SystemToolId = OptionsOrString< | "math_eval" | "md_find_files" | "md_read_frontmatter" + | "meta_prompt" + | "meta_schema" | "node_test" | "python_code_interpreter_copy_files" | "python_code_interpreter_run" diff --git a/packages/core/src/genaisrc/copilot_chat_participant.genai.mjs b/packages/core/src/genaisrc/copilot_chat_participant.genai.mjs index ff88a620f8..e7c2e99026 100644 --- a/packages/core/src/genaisrc/copilot_chat_participant.genai.mjs +++ b/packages/core/src/genaisrc/copilot_chat_participant.genai.mjs @@ -10,7 +10,6 @@ script({ "system.safety_harmful_content", ], tools: ["agent"], - excludedSystem: ["system.agent_user_input"], group: "infrastructure", parameters: { question: { diff --git a/packages/core/src/genaisrc/genaiscript.d.ts b/packages/core/src/genaisrc/genaiscript.d.ts index 6690e3ba8e..ba8452c376 100644 --- a/packages/core/src/genaisrc/genaiscript.d.ts +++ b/packages/core/src/genaisrc/genaiscript.d.ts @@ -99,6 +99,8 @@ type SystemPromptId = OptionsOrString< | "system.math" | "system.md_find_files" | "system.md_frontmatter" + | "system.meta_prompt" + | "system.meta_schema" | "system.node_info" | "system.node_test" | "system.planner" @@ -155,6 +157,8 @@ type SystemToolId = OptionsOrString< | "math_eval" | "md_find_files" | "md_read_frontmatter" + | "meta_prompt" + | "meta_schema" | "node_test" | "python_code_interpreter_copy_files" | "python_code_interpreter_run" diff --git a/packages/core/src/genaisrc/system.meta_prompt.genai.mjs b/packages/core/src/genaisrc/system.meta_prompt.genai.mjs new file mode 100644 index 0000000000..138abc946f --- /dev/null +++ b/packages/core/src/genaisrc/system.meta_prompt.genai.mjs @@ -0,0 +1,73 @@ +system({ + title: "Tool that applies OpenAI's meta prompt guidelines to a user prompt", + description: + "Modified meta-prompt tool from https://platform.openai.com/docs/guides/prompt-generation?context=text-out.", +}) + +defTool( + "meta_prompt", + "Tool that applies OpenAI's meta prompt guidelines to a user prompt. Modified from https://platform.openai.com/docs/guides/prompt-generation?context=text-out.", + { + prompt: { + type: "string", + description: + "User prompt to be converted to a detailed system prompt using OpenAI's meta prompt guidelines", + }, + }, + async ({ prompt: userPrompt }) => { + const res = await runPrompt( + (_) => { + _.$`Given a task description or existing prompt in USER_PROMPT, produce a detailed system prompt to guide a language model in completing the task effectively. + +# Guidelines + +- Understand the Task: Grasp the main objective, goals, requirements, constraints, and expected output. +- Minimal Changes: If an existing prompt is provided, improve it only if it's simple. For complex prompts, enhance clarity and add missing elements without altering the original structure. +- Reasoning Before Conclusions**: Encourage reasoning steps before any conclusions are reached. ATTENTION! If the user provides examples where the reasoning happens afterward, REVERSE the order! NEVER START EXAMPLES WITH CONCLUSIONS! + - Reasoning Order: Call out reasoning portions of the prompt and conclusion parts (specific fields by name). For each, determine the ORDER in which this is done, and whether it needs to be reversed. + - Conclusion, classifications, or results should ALWAYS appear last. +- Examples: Include high-quality examples if helpful, using placeholders [in brackets] for complex elements. + - What kinds of examples may need to be included, how many, and whether they are complex enough to benefit from placeholders. +- Clarity and Conciseness: Use clear, specific language. Avoid unnecessary instructions or bland statements. +- Formatting: Use markdown features for readability. +- Preserve User Content: If the input task or prompt includes extensive guidelines or examples, preserve them entirely, or as closely as possible. If they are vague, consider breaking down into sub-steps. Keep any details, guidelines, examples, variables, or placeholders provided by the user. +- Constants: DO include constants in the prompt, as they are not susceptible to prompt injection. Such as guides, rubrics, and examples. +- Output Format: Explicitly the most appropriate output format, in detail. This should include length and syntax (e.g. short sentence, paragraph, YAML, INI, CSV, JSON, etc.) + - For tasks outputting well-defined or structured data (classification, JSON, etc.) bias toward outputting a YAML. + +The final prompt you output should adhere to the following structure below. Do not include any additional commentary, only output the completed system prompt. SPECIFICALLY, do not include any additional messages at the start or end of the prompt. (e.g. no "---") + +[Concise instruction describing the task - this should be the first line in the prompt, no section header] + +[Additional details as needed.] + +[Optional sections with headings or bullet points for detailed steps.] + +# Steps [optional] + +[optional: a detailed breakdown of the steps necessary to accomplish the task] + +# Output Format + +[Specifically call out how the output should be formatted, be it response length, structure e.g. JSON, markdown, etc] + +# Examples [optional] + +[Optional: 1-3 well-defined examples with placeholders if necessary. Clearly mark where examples start and end, and what the input and output are. User placeholders as necessary.] +[If the examples are shorter than what a realistic example is expected to be, make a reference with () explaining how real examples should be longer / shorter / different. AND USE PLACEHOLDERS! ] + +# Notes [optional] + +[optional: edge cases, details, and an area to call or repeat out specific important considerations]` + _.def("USER_PROMPT", userPrompt) + }, + { + model: "large", + label: "meta-prompt", + system: ["system.safety_jailbreak"], + } + ) + console.log(res.text ?? res.error) + return res + } +) diff --git a/packages/core/src/genaisrc/system.meta_schema.genai.mjs b/packages/core/src/genaisrc/system.meta_schema.genai.mjs new file mode 100644 index 0000000000..fd20d23473 --- /dev/null +++ b/packages/core/src/genaisrc/system.meta_schema.genai.mjs @@ -0,0 +1,309 @@ +system({ + title: "Tool that generate a valid schema for the described JSON", + description: + "OpenAI's meta schema generator from https://platform.openai.com/docs/guides/prompt-generation?context=structured-output-schema.", +}) + +const metaSchema = Object.freeze({ + name: "metaschema", + schema: { + type: "object", + properties: { + name: { + type: "string", + description: "The name of the schema", + }, + type: { + type: "string", + enum: [ + "object", + "array", + "string", + "number", + "boolean", + "null", + ], + }, + properties: { + type: "object", + additionalProperties: { + $ref: "#/$defs/schema_definition", + }, + }, + items: { + anyOf: [ + { + $ref: "#/$defs/schema_definition", + }, + { + type: "array", + items: { + $ref: "#/$defs/schema_definition", + }, + }, + ], + }, + required: { + type: "array", + items: { + type: "string", + }, + }, + additionalProperties: { + type: "boolean", + }, + }, + required: ["type"], + additionalProperties: false, + if: { + properties: { + type: { + const: "object", + }, + }, + }, + then: { + required: ["properties"], + }, + $defs: { + schema_definition: { + type: "object", + properties: { + type: { + type: "string", + enum: [ + "object", + "array", + "string", + "number", + "boolean", + "null", + ], + }, + properties: { + type: "object", + additionalProperties: { + $ref: "#/$defs/schema_definition", + }, + }, + items: { + anyOf: [ + { + $ref: "#/$defs/schema_definition", + }, + { + type: "array", + items: { + $ref: "#/$defs/schema_definition", + }, + }, + ], + }, + required: { + type: "array", + items: { + type: "string", + }, + }, + additionalProperties: { + type: "boolean", + }, + }, + required: ["type"], + additionalProperties: false, + if: { + properties: { + type: { + const: "object", + }, + }, + }, + then: { + required: ["properties"], + }, + }, + }, + }, +}) + +defTool( + "meta_schema", + "Generate a valid JSON schema for the described JSON. Source https://platform.openai.com/docs/guides/prompt-generation?context=structured-output-schema.", + { + description: { + type: "string", + description: "Description of the JSON structure", + }, + }, + async ({ description }) => { + const res = await runPrompt( + (_) => { + _.$`# Instructions +Return a valid schema for the described JSON. + +You must also make sure: +- all fields in an object are set as required +- I REPEAT, ALL FIELDS MUST BE MARKED AS REQUIRED +- all objects must have additionalProperties set to false + - because of this, some cases like "attributes" or "metadata" properties that would normally allow additional properties should instead have a fixed set of properties +- all objects must have properties defined +- field order matters. any form of "thinking" or "explanation" should come before the conclusion +- $defs must be defined under the schema param + +Notable keywords NOT supported include: +- For strings: minLength, maxLength, pattern, format +- For numbers: minimum, maximum, multipleOf +- For objects: patternProperties, unevaluatedProperties, propertyNames, minProperties, maxProperties +- For arrays: unevaluatedItems, contains, minContains, maxContains, minItems, maxItems, uniqueItems + +Other notes: +- definitions and recursion are supported +- only if necessary to include references e.g. "$defs", it must be inside the "schema" object + +# Examples +Input: Generate a math reasoning schema with steps and a final answer. +Output: ${JSON.stringify({ + name: "math_reasoning", + type: "object", + properties: { + steps: { + type: "array", + description: + "A sequence of steps involved in solving the math problem.", + items: { + type: "object", + properties: { + explanation: { + type: "string", + description: + "Description of the reasoning or method used in this step.", + }, + output: { + type: "string", + description: + "Result or outcome of this specific step.", + }, + }, + required: ["explanation", "output"], + additionalProperties: false, + }, + }, + final_answer: { + type: "string", + description: + "The final solution or answer to the math problem.", + }, + }, + required: ["steps", "final_answer"], + additionalProperties: false, + })} + +Input: Give me a linked list +Output: ${JSON.stringify({ + name: "linked_list", + type: "object", + properties: { + linked_list: { + $ref: "#/$defs/linked_list_node", + description: "The head node of the linked list.", + }, + }, + $defs: { + linked_list_node: { + type: "object", + description: + "Defines a node in a singly linked list.", + properties: { + value: { + type: "number", + description: + "The value stored in this node.", + }, + next: { + anyOf: [ + { + $ref: "#/$defs/linked_list_node", + }, + { + type: "null", + }, + ], + description: + "Reference to the next node; null if it is the last node.", + }, + }, + required: ["value", "next"], + additionalProperties: false, + }, + }, + required: ["linked_list"], + additionalProperties: false, + })} + +Input: Dynamically generated UI +Output: ${JSON.stringify({ + name: "ui", + type: "object", + properties: { + type: { + type: "string", + description: "The type of the UI component", + enum: [ + "div", + "button", + "header", + "section", + "field", + "form", + ], + }, + label: { + type: "string", + description: + "The label of the UI component, used for buttons or form fields", + }, + children: { + type: "array", + description: "Nested UI components", + items: { + $ref: "#", + }, + }, + attributes: { + type: "array", + description: + "Arbitrary attributes for the UI component, suitable for any element", + items: { + type: "object", + properties: { + name: { + type: "string", + description: + "The name of the attribute, for example onClick or className", + }, + value: { + type: "string", + description: + "The value of the attribute", + }, + }, + required: ["name", "value"], + additionalProperties: false, + }, + }, + }, + required: ["type", "label", "children", "attributes"], + additionalProperties: false, + })}` + _.def("DESCRIPTION", description) + }, + { + model: "large", + responseSchema: metaSchema, + responseType: "json_schema", + system: ["system.safety_jailbreak"], + } + ) + return res + } +) diff --git a/packages/core/src/systems.ts b/packages/core/src/systems.ts index 37c646a9b3..73e5a66200 100644 --- a/packages/core/src/systems.ts +++ b/packages/core/src/systems.ts @@ -23,8 +23,8 @@ export function resolveSystems( if (!script.responseType) { systems.push("system") systems.push("system.explanations") - systems.push("system.safey_jailbreak") - systems.push("system.safey_harmful_content") + systems.push("system.safety_jailbreak") + systems.push("system.safety_harmful_content") } if (tools.some((t) => /^agent/.test(t))) systems.push("system.planner") diff --git a/packages/sample/genaisrc/blog/genaiscript.d.ts b/packages/sample/genaisrc/blog/genaiscript.d.ts index 6690e3ba8e..ba8452c376 100644 --- a/packages/sample/genaisrc/blog/genaiscript.d.ts +++ b/packages/sample/genaisrc/blog/genaiscript.d.ts @@ -99,6 +99,8 @@ type SystemPromptId = OptionsOrString< | "system.math" | "system.md_find_files" | "system.md_frontmatter" + | "system.meta_prompt" + | "system.meta_schema" | "system.node_info" | "system.node_test" | "system.planner" @@ -155,6 +157,8 @@ type SystemToolId = OptionsOrString< | "math_eval" | "md_find_files" | "md_read_frontmatter" + | "meta_prompt" + | "meta_schema" | "node_test" | "python_code_interpreter_copy_files" | "python_code_interpreter_run" diff --git a/packages/sample/genaisrc/genaiscript.d.ts b/packages/sample/genaisrc/genaiscript.d.ts index 6690e3ba8e..ba8452c376 100644 --- a/packages/sample/genaisrc/genaiscript.d.ts +++ b/packages/sample/genaisrc/genaiscript.d.ts @@ -99,6 +99,8 @@ type SystemPromptId = OptionsOrString< | "system.math" | "system.md_find_files" | "system.md_frontmatter" + | "system.meta_prompt" + | "system.meta_schema" | "system.node_info" | "system.node_test" | "system.planner" @@ -155,6 +157,8 @@ type SystemToolId = OptionsOrString< | "math_eval" | "md_find_files" | "md_read_frontmatter" + | "meta_prompt" + | "meta_schema" | "node_test" | "python_code_interpreter_copy_files" | "python_code_interpreter_run" diff --git a/packages/sample/genaisrc/node/genaiscript.d.ts b/packages/sample/genaisrc/node/genaiscript.d.ts index 6690e3ba8e..ba8452c376 100644 --- a/packages/sample/genaisrc/node/genaiscript.d.ts +++ b/packages/sample/genaisrc/node/genaiscript.d.ts @@ -99,6 +99,8 @@ type SystemPromptId = OptionsOrString< | "system.math" | "system.md_find_files" | "system.md_frontmatter" + | "system.meta_prompt" + | "system.meta_schema" | "system.node_info" | "system.node_test" | "system.planner" @@ -155,6 +157,8 @@ type SystemToolId = OptionsOrString< | "math_eval" | "md_find_files" | "md_read_frontmatter" + | "meta_prompt" + | "meta_schema" | "node_test" | "python_code_interpreter_copy_files" | "python_code_interpreter_run" diff --git a/packages/sample/genaisrc/python/genaiscript.d.ts b/packages/sample/genaisrc/python/genaiscript.d.ts index 6690e3ba8e..ba8452c376 100644 --- a/packages/sample/genaisrc/python/genaiscript.d.ts +++ b/packages/sample/genaisrc/python/genaiscript.d.ts @@ -99,6 +99,8 @@ type SystemPromptId = OptionsOrString< | "system.math" | "system.md_find_files" | "system.md_frontmatter" + | "system.meta_prompt" + | "system.meta_schema" | "system.node_info" | "system.node_test" | "system.planner" @@ -155,6 +157,8 @@ type SystemToolId = OptionsOrString< | "math_eval" | "md_find_files" | "md_read_frontmatter" + | "meta_prompt" + | "meta_schema" | "node_test" | "python_code_interpreter_copy_files" | "python_code_interpreter_run" diff --git a/packages/sample/genaisrc/style/genaiscript.d.ts b/packages/sample/genaisrc/style/genaiscript.d.ts index 6690e3ba8e..ba8452c376 100644 --- a/packages/sample/genaisrc/style/genaiscript.d.ts +++ b/packages/sample/genaisrc/style/genaiscript.d.ts @@ -99,6 +99,8 @@ type SystemPromptId = OptionsOrString< | "system.math" | "system.md_find_files" | "system.md_frontmatter" + | "system.meta_prompt" + | "system.meta_schema" | "system.node_info" | "system.node_test" | "system.planner" @@ -155,6 +157,8 @@ type SystemToolId = OptionsOrString< | "math_eval" | "md_find_files" | "md_read_frontmatter" + | "meta_prompt" + | "meta_schema" | "node_test" | "python_code_interpreter_copy_files" | "python_code_interpreter_run" diff --git a/packages/sample/src/aici/genaiscript.d.ts b/packages/sample/src/aici/genaiscript.d.ts index 6690e3ba8e..ba8452c376 100644 --- a/packages/sample/src/aici/genaiscript.d.ts +++ b/packages/sample/src/aici/genaiscript.d.ts @@ -99,6 +99,8 @@ type SystemPromptId = OptionsOrString< | "system.math" | "system.md_find_files" | "system.md_frontmatter" + | "system.meta_prompt" + | "system.meta_schema" | "system.node_info" | "system.node_test" | "system.planner" @@ -155,6 +157,8 @@ type SystemToolId = OptionsOrString< | "math_eval" | "md_find_files" | "md_read_frontmatter" + | "meta_prompt" + | "meta_schema" | "node_test" | "python_code_interpreter_copy_files" | "python_code_interpreter_run" diff --git a/packages/sample/src/errors/genaiscript.d.ts b/packages/sample/src/errors/genaiscript.d.ts index 6690e3ba8e..ba8452c376 100644 --- a/packages/sample/src/errors/genaiscript.d.ts +++ b/packages/sample/src/errors/genaiscript.d.ts @@ -99,6 +99,8 @@ type SystemPromptId = OptionsOrString< | "system.math" | "system.md_find_files" | "system.md_frontmatter" + | "system.meta_prompt" + | "system.meta_schema" | "system.node_info" | "system.node_test" | "system.planner" @@ -155,6 +157,8 @@ type SystemToolId = OptionsOrString< | "math_eval" | "md_find_files" | "md_read_frontmatter" + | "meta_prompt" + | "meta_schema" | "node_test" | "python_code_interpreter_copy_files" | "python_code_interpreter_run" diff --git a/packages/sample/src/genaiscript.d.ts b/packages/sample/src/genaiscript.d.ts index 6690e3ba8e..ba8452c376 100644 --- a/packages/sample/src/genaiscript.d.ts +++ b/packages/sample/src/genaiscript.d.ts @@ -99,6 +99,8 @@ type SystemPromptId = OptionsOrString< | "system.math" | "system.md_find_files" | "system.md_frontmatter" + | "system.meta_prompt" + | "system.meta_schema" | "system.node_info" | "system.node_test" | "system.planner" @@ -155,6 +157,8 @@ type SystemToolId = OptionsOrString< | "math_eval" | "md_find_files" | "md_read_frontmatter" + | "meta_prompt" + | "meta_schema" | "node_test" | "python_code_interpreter_copy_files" | "python_code_interpreter_run" diff --git a/packages/sample/src/makecode/genaiscript.d.ts b/packages/sample/src/makecode/genaiscript.d.ts index 6690e3ba8e..ba8452c376 100644 --- a/packages/sample/src/makecode/genaiscript.d.ts +++ b/packages/sample/src/makecode/genaiscript.d.ts @@ -99,6 +99,8 @@ type SystemPromptId = OptionsOrString< | "system.math" | "system.md_find_files" | "system.md_frontmatter" + | "system.meta_prompt" + | "system.meta_schema" | "system.node_info" | "system.node_test" | "system.planner" @@ -155,6 +157,8 @@ type SystemToolId = OptionsOrString< | "math_eval" | "md_find_files" | "md_read_frontmatter" + | "meta_prompt" + | "meta_schema" | "node_test" | "python_code_interpreter_copy_files" | "python_code_interpreter_run" diff --git a/packages/sample/src/tla/genaiscript.d.ts b/packages/sample/src/tla/genaiscript.d.ts index 6690e3ba8e..ba8452c376 100644 --- a/packages/sample/src/tla/genaiscript.d.ts +++ b/packages/sample/src/tla/genaiscript.d.ts @@ -99,6 +99,8 @@ type SystemPromptId = OptionsOrString< | "system.math" | "system.md_find_files" | "system.md_frontmatter" + | "system.meta_prompt" + | "system.meta_schema" | "system.node_info" | "system.node_test" | "system.planner" @@ -155,6 +157,8 @@ type SystemToolId = OptionsOrString< | "math_eval" | "md_find_files" | "md_read_frontmatter" + | "meta_prompt" + | "meta_schema" | "node_test" | "python_code_interpreter_copy_files" | "python_code_interpreter_run" diff --git a/packages/sample/src/vision/genaiscript.d.ts b/packages/sample/src/vision/genaiscript.d.ts index 6690e3ba8e..ba8452c376 100644 --- a/packages/sample/src/vision/genaiscript.d.ts +++ b/packages/sample/src/vision/genaiscript.d.ts @@ -99,6 +99,8 @@ type SystemPromptId = OptionsOrString< | "system.math" | "system.md_find_files" | "system.md_frontmatter" + | "system.meta_prompt" + | "system.meta_schema" | "system.node_info" | "system.node_test" | "system.planner" @@ -155,6 +157,8 @@ type SystemToolId = OptionsOrString< | "math_eval" | "md_find_files" | "md_read_frontmatter" + | "meta_prompt" + | "meta_schema" | "node_test" | "python_code_interpreter_copy_files" | "python_code_interpreter_run" diff --git a/packages/vscode/genaisrc/genaiscript.d.ts b/packages/vscode/genaisrc/genaiscript.d.ts index 6690e3ba8e..ba8452c376 100644 --- a/packages/vscode/genaisrc/genaiscript.d.ts +++ b/packages/vscode/genaisrc/genaiscript.d.ts @@ -99,6 +99,8 @@ type SystemPromptId = OptionsOrString< | "system.math" | "system.md_find_files" | "system.md_frontmatter" + | "system.meta_prompt" + | "system.meta_schema" | "system.node_info" | "system.node_test" | "system.planner" @@ -155,6 +157,8 @@ type SystemToolId = OptionsOrString< | "math_eval" | "md_find_files" | "md_read_frontmatter" + | "meta_prompt" + | "meta_schema" | "node_test" | "python_code_interpreter_copy_files" | "python_code_interpreter_run" diff --git a/slides/genaisrc/genaiscript.d.ts b/slides/genaisrc/genaiscript.d.ts index 6690e3ba8e..ba8452c376 100644 --- a/slides/genaisrc/genaiscript.d.ts +++ b/slides/genaisrc/genaiscript.d.ts @@ -99,6 +99,8 @@ type SystemPromptId = OptionsOrString< | "system.math" | "system.md_find_files" | "system.md_frontmatter" + | "system.meta_prompt" + | "system.meta_schema" | "system.node_info" | "system.node_test" | "system.planner" @@ -155,6 +157,8 @@ type SystemToolId = OptionsOrString< | "math_eval" | "md_find_files" | "md_read_frontmatter" + | "meta_prompt" + | "meta_schema" | "node_test" | "python_code_interpreter_copy_files" | "python_code_interpreter_run" From d2d911fc7f44d0db6ae01094dfd8294cbe7f4952 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 11 Oct 2024 13:40:38 +0000 Subject: [PATCH 2/4] =?UTF-8?q?=E2=9C=A8=20feat:=20add=20large=20model=20l?= =?UTF-8?q?abel=20for=20commit=20message=20generation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/vscode/genaisrc/gcm.genai.mts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/vscode/genaisrc/gcm.genai.mts b/packages/vscode/genaisrc/gcm.genai.mts index 0610fed069..a22fb9b25b 100644 --- a/packages/vscode/genaisrc/gcm.genai.mts +++ b/packages/vscode/genaisrc/gcm.genai.mts @@ -33,6 +33,8 @@ do { ` }, { + model: "large", + label: "generate commit message", system: [ "system.safety_jailbreak", "system.safety_harmful_content", From 3bb5bb39e1d88e59913255a5ad96851c631eff02 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 11 Oct 2024 13:45:32 +0000 Subject: [PATCH 3/4] =?UTF-8?q?Add=20comments=20and=20improve=20documentat?= =?UTF-8?q?ion=20throughout=20the=20codebase=20to=20enhance=20clarity=20an?= =?UTF-8?q?d=20maintainability=20=F0=9F=93=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../copilot_chat_participant.genai.mjs | 16 ++++++--- .../src/genaisrc/system.meta_prompt.genai.mjs | 11 ++++++ packages/core/src/systems.ts | 36 ++++++++++++++++--- packages/vscode/genaisrc/cmt.genai.mts | 2 +- packages/vscode/genaisrc/gcm.genai.mts | 20 ++++++----- 5 files changed, 67 insertions(+), 18 deletions(-) diff --git a/packages/core/src/genaisrc/copilot_chat_participant.genai.mjs b/packages/core/src/genaisrc/copilot_chat_participant.genai.mjs index e7c2e99026..ddd826e4f6 100644 --- a/packages/core/src/genaisrc/copilot_chat_participant.genai.mjs +++ b/packages/core/src/genaisrc/copilot_chat_participant.genai.mjs @@ -1,5 +1,6 @@ script({ system: [ + // List of system components and tools available for the script "system", "system.tools", "system.files", @@ -9,17 +10,18 @@ script({ "system.github_info", "system.safety_harmful_content", ], - tools: ["agent"], - group: "infrastructure", + tools: ["agent"], // Tools that the script can use + group: "infrastructure", // Group categorization for the script parameters: { question: { - type: "string", - description: "the user question", + type: "string", // Type of the parameter + description: "the user question", // Description of the parameter }, }, - flexTokens: 20000, + flexTokens: 20000, // Flexible token limit for the script }) +// Extract the 'question' parameter from the environment variables const { question } = env.vars $`## task @@ -33,5 +35,9 @@ $`## task - do NOT skip any steps ` +// Define a variable QUESTION with the value of 'question' def("QUESTION", question) + +// Define a variable FILE with the file data from the environment variables +// The { ignoreEmpty: true, flex: 1 } options specify to ignore empty files and to use flexible token allocation def("FILE", env.files, { ignoreEmpty: true, flex: 1 }) diff --git a/packages/core/src/genaisrc/system.meta_prompt.genai.mjs b/packages/core/src/genaisrc/system.meta_prompt.genai.mjs index 138abc946f..406810e843 100644 --- a/packages/core/src/genaisrc/system.meta_prompt.genai.mjs +++ b/packages/core/src/genaisrc/system.meta_prompt.genai.mjs @@ -1,19 +1,26 @@ +// This module defines a system tool that applies OpenAI's meta prompt guidelines to a user-provided prompt. +// The tool refines a given prompt to create a detailed system prompt designed to guide a language model for task completion. + system({ + // Metadata for the tool title: "Tool that applies OpenAI's meta prompt guidelines to a user prompt", description: "Modified meta-prompt tool from https://platform.openai.com/docs/guides/prompt-generation?context=text-out.", }) +// Define the 'meta_prompt' tool with its properties and functionality defTool( "meta_prompt", "Tool that applies OpenAI's meta prompt guidelines to a user prompt. Modified from https://platform.openai.com/docs/guides/prompt-generation?context=text-out.", { + // Input parameter for the tool prompt: { type: "string", description: "User prompt to be converted to a detailed system prompt using OpenAI's meta prompt guidelines", }, }, + // Asynchronous function that processes the user prompt async ({ prompt: userPrompt }) => { const res = await runPrompt( (_) => { @@ -62,11 +69,15 @@ The final prompt you output should adhere to the following structure below. Do n _.def("USER_PROMPT", userPrompt) }, { + // Specify the model to be used model: "large", + // Label for the prompt run label: "meta-prompt", + // System configuration, including safety mechanisms system: ["system.safety_jailbreak"], } ) + // Log the result or any errors for debugging purposes console.log(res.text ?? res.error) return res } diff --git a/packages/core/src/systems.ts b/packages/core/src/systems.ts index 73e5a66200..adff8ac324 100644 --- a/packages/core/src/systems.ts +++ b/packages/core/src/systems.ts @@ -1,9 +1,18 @@ +// This module resolves and returns a list of applicable systems based on the provided script and project. +// It analyzes script options and the JavaScript source code to determine which systems to include or exclude. + import { uniq } from "es-toolkit" import { Project } from "./ast" import { arrayify } from "./util" -// Function to resolve and return a list of systems based on the provided script and project -// Analyzes script options and JavaScript source code to determine applicable systems. +/** + * Function to resolve and return a list of systems based on the provided script and project. + * This function analyzes the script options and JavaScript source code to determine applicable systems. + * + * @param prj - The project object containing templates and other project-related data. + * @param script - An object containing options for the prompt system, model options, and optionally JavaScript source code. + * @returns An array of unique system IDs that are applicable based on the analysis. + */ export function resolveSystems( prj: Project, script: PromptSystemOptions & ModelOptions & { jsSource?: string } @@ -27,7 +36,9 @@ export function resolveSystems( systems.push("system.safety_harmful_content") } + // Add planner system if any tool starts with "agent" if (tools.some((t) => /^agent/.test(t))) systems.push("system.planner") + // Add harmful content system if images are defined if (/\Wdefimages\W/i.test(jsSource)) systems.push("system.safety_harmful_content") // Determine additional systems based on content of jsSource @@ -45,7 +56,9 @@ export function resolveSystems( // Add diagram system if diagrams or charts are found if (/\W(diagram|chart)\W/i.test(jsSource)) systems.push("system.diagrams") + // Add git information system if git is found if (/\W(git)\W/i.test(jsSource)) systems.push("system.git_info") + // Add GitHub information system if GitHub is found if (/\W(github)\W/i.test(jsSource)) systems.push("system.github_info") } @@ -66,8 +79,14 @@ export function resolveSystems( return res } -// Helper function to resolve tools in the project and return their system IDs -// Finds systems in the project associated with a specific tool +/** + * Helper function to resolve tools in the project and return their system IDs. + * Finds systems in the project associated with a specific tool. + * + * @param prj - The project object containing templates and other project-related data. + * @param tool - The tool ID to resolve systems for. + * @returns An array of system IDs associated with the specified tool. + */ function resolveSystemFromTools(prj: Project, tool: string): string[] { const system = prj.templates.filter( (t) => t.isSystem && t.defTools?.find((to) => to.id.startsWith(tool)) @@ -77,6 +96,15 @@ function resolveSystemFromTools(prj: Project, tool: string): string[] { return res } +/** + * Function to resolve tools in the project based on provided systems and tools. + * This function returns a list of tool objects with their IDs and descriptions. + * + * @param prj - The project object containing templates and other project-related data. + * @param systems - An array of system IDs to resolve tools for. + * @param tools - An array of tool IDs to resolve tools for. + * @returns An array of tool objects containing their IDs and descriptions. + */ export function resolveTools( prj: Project, systems: string[], diff --git a/packages/vscode/genaisrc/cmt.genai.mts b/packages/vscode/genaisrc/cmt.genai.mts index 6af84abfd7..113c26e55c 100644 --- a/packages/vscode/genaisrc/cmt.genai.mts +++ b/packages/vscode/genaisrc/cmt.genai.mts @@ -32,7 +32,7 @@ files = files.filter( files = files.sort(() => Math.random() - 0.5) console.log(YAML.stringify(files.map((f) => f.filename))) - +cancel("done") // Process each file separately to avoid context explosion const jobs = host.promiseQueue(5) await jobs.mapAll(files, processFile) diff --git a/packages/vscode/genaisrc/gcm.genai.mts b/packages/vscode/genaisrc/gcm.genai.mts index a22fb9b25b..f6e70f6476 100644 --- a/packages/vscode/genaisrc/gcm.genai.mts +++ b/packages/vscode/genaisrc/gcm.genai.mts @@ -1,6 +1,8 @@ /** - * git commit flow with auto-generated commit message + * Script to automate the git commit process with AI-generated commit messages. + * It checks for staged changes, generates a commit message, and prompts the user to review or edit the message before committing. */ + script({ title: "git commit message", description: "Generate a commit message for all staged changes", @@ -11,15 +13,17 @@ const diff = await git.diff({ staged: true, askStageOnEmpty: true, }) + +// If no staged changes are found, cancel the script with a message if (!diff) cancel("no staged changes") -// show diff in the console +// Display the diff of staged changes in the console console.log(diff) let choice let message do { - // generate a conventional commit message (https://www.conventionalcommits.org/en/v1.0.0/) + // Generate a conventional commit message based on the staged changes diff const res = await runPrompt( (_) => { _.def("GIT_DIFF", diff, { maxTokens: 20000, language: "diff" }) @@ -33,8 +37,8 @@ do { ` }, { - model: "large", - label: "generate commit message", + model: "large", // Specifies the LLM model to use for message generation + label: "generate commit message", // Label for the prompt task system: [ "system.safety_jailbreak", "system.safety_harmful_content", @@ -50,7 +54,7 @@ do { break } - // Prompt user for commit message + // Prompt user to accept, edit, or regenerate the commit message choice = await host.select(message, [ { value: "commit", @@ -66,14 +70,14 @@ do { }, ]) - // Handle user choice + // Handle user's choice for commit message if (choice === "edit") { message = await host.input("Edit commit message", { required: true, }) choice = "commit" } - // Regenerate message + // If user chooses to commit, execute the git commit and optionally push changes if (choice === "commit" && message) { console.log(await git.exec(["commit", "-m", message])) if (await host.confirm("Push changes?", { default: true })) From c674b1584085661c890289930e3253c555d62e09 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 11 Oct 2024 13:46:46 +0000 Subject: [PATCH 4/4] =?UTF-8?q?refactor:=20=E2=9C=A8=20remove=20unnecessar?= =?UTF-8?q?y=20cancel=20line?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/vscode/genaisrc/cmt.genai.mts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vscode/genaisrc/cmt.genai.mts b/packages/vscode/genaisrc/cmt.genai.mts index 113c26e55c..6af84abfd7 100644 --- a/packages/vscode/genaisrc/cmt.genai.mts +++ b/packages/vscode/genaisrc/cmt.genai.mts @@ -32,7 +32,7 @@ files = files.filter( files = files.sort(() => Math.random() - 0.5) console.log(YAML.stringify(files.map((f) => f.filename))) -cancel("done") + // Process each file separately to avoid context explosion const jobs = host.promiseQueue(5) await jobs.mapAll(files, processFile)