Skip to content

Commit

Permalink
docs: 💡 Add comments to clarify script components and tools
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Oct 11, 2024
1 parent 55ba7e8 commit 69a255a
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions docs/src/content/docs/reference/scripts/system.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ generating annotations. If unspecified, GenAIScript looks for specific keywords
`````js wrap title="copilot_chat_participant"
script({
system: [
// List of system components and tools available for the script
"system",
"system.tools",
"system.files",
Expand All @@ -98,17 +99,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
Expand All @@ -122,7 +124,11 @@ $`## 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 })

`````
Expand Down Expand Up @@ -1900,22 +1906,29 @@ Modified meta-prompt tool from https://platform.openai.com/docs/guides/prompt-ge
- 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"
// 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(
(_) => {
Expand Down Expand Up @@ -1964,11 +1977,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
}
Expand Down

0 comments on commit 69a255a

Please sign in to comment.