From 254ddb6d4519f5a248b1c857199983e0a6db361a Mon Sep 17 00:00:00 2001 From: pelikhan Date: Tue, 13 Aug 2024 15:13:21 -0700 Subject: [PATCH 1/5] connect disconnect --- docs/genaisrc/genaiscript.d.ts | 12 +++-- docs/src/components/BuiltinTools.mdx | 1 - .../content/docs/reference/scripts/system.mdx | 47 +++++++--------- genaisrc/genaiscript.d.ts | 12 +++-- packages/cli/src/docker.ts | 12 +++++ packages/core/src/genaisrc/genaiscript.d.ts | 12 +++-- .../system.python_code_interpreter.genai.js | 48 +++++++++++++++++ .../system.python_interpreter.genai.js | 54 ------------------- packages/core/src/types/prompt_template.d.ts | 5 ++ .../sample/genaisrc/data-analyst.genai.mjs | 3 +- packages/sample/genaisrc/genaiscript.d.ts | 12 +++-- .../sample/genaisrc/node/genaiscript.d.ts | 12 +++-- .../sample/genaisrc/python/genaiscript.d.ts | 12 +++-- .../sample/genaisrc/style/genaiscript.d.ts | 12 +++-- packages/sample/src/aici/genaiscript.d.ts | 12 +++-- packages/sample/src/errors/genaiscript.d.ts | 12 +++-- packages/sample/src/makecode/genaiscript.d.ts | 12 +++-- packages/sample/src/tla/genaiscript.d.ts | 12 +++-- packages/sample/src/vision/genaiscript.d.ts | 12 +++-- slides/genaisrc/genaiscript.d.ts | 12 +++-- 20 files changed, 191 insertions(+), 135 deletions(-) create mode 100644 packages/core/src/genaisrc/system.python_code_interpreter.genai.js delete mode 100644 packages/core/src/genaisrc/system.python_interpreter.genai.js diff --git a/docs/genaisrc/genaiscript.d.ts b/docs/genaisrc/genaiscript.d.ts index 8fccf3c5fa..3f0a6543c7 100644 --- a/docs/genaisrc/genaiscript.d.ts +++ b/docs/genaisrc/genaiscript.d.ts @@ -67,9 +67,9 @@ interface PromptLike extends PromptDefinition { text?: string } -type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> +type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_code_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> -type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "python_interpreter" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> +type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> type FileMergeHandler = ( filename: string, @@ -212,7 +212,7 @@ interface ScriptRuntimeOptions { * - `system.functions`: use functions * - `system.math`: Math expression evaluator * - `system.python`: Expert at generating and understanding Python code. -* - `system.python_interpreter`: Python Dockerized code execution +* - `system.python_code_interpreter`: Python Dockerized code execution for data analysis * - `system.retrieval_fuzz_search`: Full Text Fuzzy Search * - `system.retrieval_vector_search`: Embeddings Vector Search * - `system.retrieval_web_search`: Web Search @@ -233,7 +233,6 @@ interface ScriptRuntimeOptions { * - `fs_read_file`: Reads a file as text from the file system. * - `fs_read_summary`: Reads a summary of a file from the file system. * - `math_eval`: Evaluates a math expression -* - `python_interpreter`: Executes python 3.12 code in a docker container. The process output is returned. Use 'print' to output data. * - `retrieval_fuzz_search`: Search for keywords using the full text of files and a fuzzy distance. * - `retrieval_vector_search`: Search files using embeddings and similarity distance. * - `retrieval_web_search`: Search the web for a user query using Bing Search. @@ -1631,6 +1630,11 @@ interface ContainerHost extends ShellHost { * Stops and cleans out the container */ stop(): Promise + + /** + * Force disconnect network + */ + disconnect(): Promise } interface PromptContext extends ChatGenerationContext { diff --git a/docs/src/components/BuiltinTools.mdx b/docs/src/components/BuiltinTools.mdx index 83dec7df0f..acd6b4c9fc 100644 --- a/docs/src/components/BuiltinTools.mdx +++ b/docs/src/components/BuiltinTools.mdx @@ -10,7 +10,6 @@ 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 f97f59743b..8f6c1655c1 100644 --- a/docs/src/content/docs/reference/scripts/system.mdx +++ b/docs/src/content/docs/reference/scripts/system.mdx @@ -590,64 +590,57 @@ Emit type information compatible with PyLance.` ````` -### `system.python_interpreter` +### `system.python_code_interpreter` -Python Dockerized code execution +Python Dockerized code execution for data analysis -- tool `python_interpreter`: Executes python 3.12 code in a docker container. The process output is returned. Use 'print' to output data. -`````js wrap title="system.python_interpreter" + +`````js wrap title="system.python_code_interpreter" system({ - title: "Python Dockerized code execution", + title: "Python Dockerized code execution for data analysis", }) const image = env.vars.pythonImage ?? "python:3.12" +const packages = ["numpy", "pandas", "scipy"] let container = null defTool( - "python_interpreter", - "Executes python 3.12 code in a docker container. The process output is returned. Use 'print' to output data.", + "python_code_interpreter", + `Executes python 3.12 code for Data Analysis tasks in a docker container. +- The process output is returned. +- Do not generate visualizations. +- The only packages available are ${packages.join(", ")}. +- There is NO network connectivity. Do not attempt to install other packages or make web requests.`, { type: "object", properties: { - requirements: { - type: "string", - description: `list of pip packages to install using pip. should be using the pip install format: - - -`, - }, main: { type: "string", description: "python 3.12 source code to execute", }, }, - required: ["requirements", "main"], + required: ["main"], }, async (args) => { - const { requirements, main = "" } = args - console.log(`python: running code...`) - container = await host.container({ image, networkEnabled: true }) - if (requirements) { - console.log(`installing: ` + requirements) - await container.writeText( - "requirements.txt", - requirements.replace(/[ ,]\s*/g, "\n") - ) + const { main = "" } = args + console.log(`python code interpreter: ` + main) + if (!container) { + console.log(`python: preparing container...`) + container = await host.container({ image, networkEnabled: true }) const res = await container.exec("pip", [ "install", "--root-user-action", "ignore", - "-r", - "requirements.txt", + ...packages, ]) if (res.failed) throw new Error(`Failed to install requirements`) + await container.disconnect() } - console.log(`code: ` + main) await container.writeText("main.py", main) const res = await container.exec("python", ["main.py"]) return res diff --git a/genaisrc/genaiscript.d.ts b/genaisrc/genaiscript.d.ts index 8fccf3c5fa..3f0a6543c7 100644 --- a/genaisrc/genaiscript.d.ts +++ b/genaisrc/genaiscript.d.ts @@ -67,9 +67,9 @@ interface PromptLike extends PromptDefinition { text?: string } -type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> +type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_code_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> -type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "python_interpreter" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> +type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> type FileMergeHandler = ( filename: string, @@ -212,7 +212,7 @@ interface ScriptRuntimeOptions { * - `system.functions`: use functions * - `system.math`: Math expression evaluator * - `system.python`: Expert at generating and understanding Python code. -* - `system.python_interpreter`: Python Dockerized code execution +* - `system.python_code_interpreter`: Python Dockerized code execution for data analysis * - `system.retrieval_fuzz_search`: Full Text Fuzzy Search * - `system.retrieval_vector_search`: Embeddings Vector Search * - `system.retrieval_web_search`: Web Search @@ -233,7 +233,6 @@ interface ScriptRuntimeOptions { * - `fs_read_file`: Reads a file as text from the file system. * - `fs_read_summary`: Reads a summary of a file from the file system. * - `math_eval`: Evaluates a math expression -* - `python_interpreter`: Executes python 3.12 code in a docker container. The process output is returned. Use 'print' to output data. * - `retrieval_fuzz_search`: Search for keywords using the full text of files and a fuzzy distance. * - `retrieval_vector_search`: Search files using embeddings and similarity distance. * - `retrieval_web_search`: Search the web for a user query using Bing Search. @@ -1631,6 +1630,11 @@ interface ContainerHost extends ShellHost { * Stops and cleans out the container */ stop(): Promise + + /** + * Force disconnect network + */ + disconnect(): Promise } interface PromptContext extends ChatGenerationContext { diff --git a/packages/cli/src/docker.ts b/packages/cli/src/docker.ts index af3885f5d3..3e4b570041 100644 --- a/packages/cli/src/docker.ts +++ b/packages/cli/src/docker.ts @@ -299,6 +299,17 @@ export class DockerManager { } } + const disconnect = async () => { + const networks = await this._docker.listNetworks() + for (const network of networks.filter( + (n) => n.Name !== "bridge" + )) { + console.log(`container: disconnect ${network.Name}`) + const n = await this._docker.getNetwork(network.Id) + if (n) await n.disconnect({ Container: container.id }) + } + } + const c = { id: container.id, disablePurge: !!options.disablePurge, @@ -309,6 +320,7 @@ export class DockerManager { writeText, readText, copyTo, + disconnect, } this.containers.push(c) await container.start() diff --git a/packages/core/src/genaisrc/genaiscript.d.ts b/packages/core/src/genaisrc/genaiscript.d.ts index 8fccf3c5fa..3f0a6543c7 100644 --- a/packages/core/src/genaisrc/genaiscript.d.ts +++ b/packages/core/src/genaisrc/genaiscript.d.ts @@ -67,9 +67,9 @@ interface PromptLike extends PromptDefinition { text?: string } -type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> +type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_code_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> -type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "python_interpreter" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> +type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> type FileMergeHandler = ( filename: string, @@ -212,7 +212,7 @@ interface ScriptRuntimeOptions { * - `system.functions`: use functions * - `system.math`: Math expression evaluator * - `system.python`: Expert at generating and understanding Python code. -* - `system.python_interpreter`: Python Dockerized code execution +* - `system.python_code_interpreter`: Python Dockerized code execution for data analysis * - `system.retrieval_fuzz_search`: Full Text Fuzzy Search * - `system.retrieval_vector_search`: Embeddings Vector Search * - `system.retrieval_web_search`: Web Search @@ -233,7 +233,6 @@ interface ScriptRuntimeOptions { * - `fs_read_file`: Reads a file as text from the file system. * - `fs_read_summary`: Reads a summary of a file from the file system. * - `math_eval`: Evaluates a math expression -* - `python_interpreter`: Executes python 3.12 code in a docker container. The process output is returned. Use 'print' to output data. * - `retrieval_fuzz_search`: Search for keywords using the full text of files and a fuzzy distance. * - `retrieval_vector_search`: Search files using embeddings and similarity distance. * - `retrieval_web_search`: Search the web for a user query using Bing Search. @@ -1631,6 +1630,11 @@ interface ContainerHost extends ShellHost { * Stops and cleans out the container */ stop(): Promise + + /** + * Force disconnect network + */ + disconnect(): Promise } interface PromptContext extends ChatGenerationContext { diff --git a/packages/core/src/genaisrc/system.python_code_interpreter.genai.js b/packages/core/src/genaisrc/system.python_code_interpreter.genai.js new file mode 100644 index 0000000000..f7d4ae75c0 --- /dev/null +++ b/packages/core/src/genaisrc/system.python_code_interpreter.genai.js @@ -0,0 +1,48 @@ +system({ + title: "Python Dockerized code execution for data analysis", +}) + +const image = env.vars.pythonImage ?? "python:3.12" +const packages = ["numpy", "pandas", "scipy"] + +let container = null + +defTool( + "python_code_interpreter", + `Executes python 3.12 code for Data Analysis tasks in a docker container. +- The process output is returned. +- Do not generate visualizations. +- The only packages available are ${packages.join(", ")}. +- There is NO network connectivity. Do not attempt to install other packages or make web requests.`, + { + type: "object", + properties: { + main: { + type: "string", + description: "python 3.12 source code to execute", + }, + }, + required: ["main"], + }, + async (args) => { + const { main = "" } = args + console.log(`python code interpreter: ` + main) + if (!container) { + console.log(`python: preparing container...`) + container = await host.container({ image, networkEnabled: true }) + await container.disconnect() + const res = await container.exec("pip", [ + "install", + "--root-user-action", + "ignore", + ...packages, + ]) + if (res.failed) throw new Error(`Failed to install requirements`) + await container.disconnect() + } + + await container.writeText("main.py", main) + const res = await container.exec("python", ["main.py"]) + return res + } +) diff --git a/packages/core/src/genaisrc/system.python_interpreter.genai.js b/packages/core/src/genaisrc/system.python_interpreter.genai.js deleted file mode 100644 index 8e886116b2..0000000000 --- a/packages/core/src/genaisrc/system.python_interpreter.genai.js +++ /dev/null @@ -1,54 +0,0 @@ -system({ - title: "Python Dockerized code execution", -}) - -const image = env.vars.pythonImage ?? "python:3.12" - -let container = null - -defTool( - "python_interpreter", - "Executes python 3.12 code in a docker container. The process output is returned. Use 'print' to output data.", - { - type: "object", - properties: { - requirements: { - type: "string", - description: `list of pip packages to install using pip. should be using the pip install format: - - -`, - }, - main: { - type: "string", - description: "python 3.12 source code to execute", - }, - }, - required: ["requirements", "main"], - }, - async (args) => { - const { requirements, main = "" } = args - console.log(`python: running code...`) - container = await host.container({ image, networkEnabled: true }) - if (requirements) { - console.log(`installing: ` + requirements) - await container.writeText( - "requirements.txt", - requirements.replace(/[ ,]\s*/g, "\n") - ) - const res = await container.exec("pip", [ - "install", - "--root-user-action", - "ignore", - "-r", - "requirements.txt", - ]) - if (res.failed) throw new Error(`Failed to install requirements`) - } - - console.log(`code: ` + main) - await container.writeText("main.py", main) - const res = await container.exec("python", ["main.py"]) - return res - } -) diff --git a/packages/core/src/types/prompt_template.d.ts b/packages/core/src/types/prompt_template.d.ts index 92973d4113..be33b2c7b7 100644 --- a/packages/core/src/types/prompt_template.d.ts +++ b/packages/core/src/types/prompt_template.d.ts @@ -1594,6 +1594,11 @@ interface ContainerHost extends ShellHost { * Stops and cleans out the container */ stop(): Promise + + /** + * Force disconnect network + */ + disconnect(): Promise } interface PromptContext extends ChatGenerationContext { diff --git a/packages/sample/genaisrc/data-analyst.genai.mjs b/packages/sample/genaisrc/data-analyst.genai.mjs index 93a9b24ccd..2288a64781 100644 --- a/packages/sample/genaisrc/data-analyst.genai.mjs +++ b/packages/sample/genaisrc/data-analyst.genai.mjs @@ -1,5 +1,6 @@ script({ - system: ["system", "system.python_interpreter"], + system: ["system"], + tools: ["python_code_interpreter"], files: ["src/penguins.csv"], }) diff --git a/packages/sample/genaisrc/genaiscript.d.ts b/packages/sample/genaisrc/genaiscript.d.ts index 8fccf3c5fa..3f0a6543c7 100644 --- a/packages/sample/genaisrc/genaiscript.d.ts +++ b/packages/sample/genaisrc/genaiscript.d.ts @@ -67,9 +67,9 @@ interface PromptLike extends PromptDefinition { text?: string } -type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> +type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_code_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> -type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "python_interpreter" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> +type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> type FileMergeHandler = ( filename: string, @@ -212,7 +212,7 @@ interface ScriptRuntimeOptions { * - `system.functions`: use functions * - `system.math`: Math expression evaluator * - `system.python`: Expert at generating and understanding Python code. -* - `system.python_interpreter`: Python Dockerized code execution +* - `system.python_code_interpreter`: Python Dockerized code execution for data analysis * - `system.retrieval_fuzz_search`: Full Text Fuzzy Search * - `system.retrieval_vector_search`: Embeddings Vector Search * - `system.retrieval_web_search`: Web Search @@ -233,7 +233,6 @@ interface ScriptRuntimeOptions { * - `fs_read_file`: Reads a file as text from the file system. * - `fs_read_summary`: Reads a summary of a file from the file system. * - `math_eval`: Evaluates a math expression -* - `python_interpreter`: Executes python 3.12 code in a docker container. The process output is returned. Use 'print' to output data. * - `retrieval_fuzz_search`: Search for keywords using the full text of files and a fuzzy distance. * - `retrieval_vector_search`: Search files using embeddings and similarity distance. * - `retrieval_web_search`: Search the web for a user query using Bing Search. @@ -1631,6 +1630,11 @@ interface ContainerHost extends ShellHost { * Stops and cleans out the container */ stop(): Promise + + /** + * Force disconnect network + */ + disconnect(): Promise } interface PromptContext extends ChatGenerationContext { diff --git a/packages/sample/genaisrc/node/genaiscript.d.ts b/packages/sample/genaisrc/node/genaiscript.d.ts index 8fccf3c5fa..3f0a6543c7 100644 --- a/packages/sample/genaisrc/node/genaiscript.d.ts +++ b/packages/sample/genaisrc/node/genaiscript.d.ts @@ -67,9 +67,9 @@ interface PromptLike extends PromptDefinition { text?: string } -type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> +type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_code_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> -type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "python_interpreter" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> +type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> type FileMergeHandler = ( filename: string, @@ -212,7 +212,7 @@ interface ScriptRuntimeOptions { * - `system.functions`: use functions * - `system.math`: Math expression evaluator * - `system.python`: Expert at generating and understanding Python code. -* - `system.python_interpreter`: Python Dockerized code execution +* - `system.python_code_interpreter`: Python Dockerized code execution for data analysis * - `system.retrieval_fuzz_search`: Full Text Fuzzy Search * - `system.retrieval_vector_search`: Embeddings Vector Search * - `system.retrieval_web_search`: Web Search @@ -233,7 +233,6 @@ interface ScriptRuntimeOptions { * - `fs_read_file`: Reads a file as text from the file system. * - `fs_read_summary`: Reads a summary of a file from the file system. * - `math_eval`: Evaluates a math expression -* - `python_interpreter`: Executes python 3.12 code in a docker container. The process output is returned. Use 'print' to output data. * - `retrieval_fuzz_search`: Search for keywords using the full text of files and a fuzzy distance. * - `retrieval_vector_search`: Search files using embeddings and similarity distance. * - `retrieval_web_search`: Search the web for a user query using Bing Search. @@ -1631,6 +1630,11 @@ interface ContainerHost extends ShellHost { * Stops and cleans out the container */ stop(): Promise + + /** + * Force disconnect network + */ + disconnect(): Promise } interface PromptContext extends ChatGenerationContext { diff --git a/packages/sample/genaisrc/python/genaiscript.d.ts b/packages/sample/genaisrc/python/genaiscript.d.ts index 8fccf3c5fa..3f0a6543c7 100644 --- a/packages/sample/genaisrc/python/genaiscript.d.ts +++ b/packages/sample/genaisrc/python/genaiscript.d.ts @@ -67,9 +67,9 @@ interface PromptLike extends PromptDefinition { text?: string } -type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> +type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_code_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> -type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "python_interpreter" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> +type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> type FileMergeHandler = ( filename: string, @@ -212,7 +212,7 @@ interface ScriptRuntimeOptions { * - `system.functions`: use functions * - `system.math`: Math expression evaluator * - `system.python`: Expert at generating and understanding Python code. -* - `system.python_interpreter`: Python Dockerized code execution +* - `system.python_code_interpreter`: Python Dockerized code execution for data analysis * - `system.retrieval_fuzz_search`: Full Text Fuzzy Search * - `system.retrieval_vector_search`: Embeddings Vector Search * - `system.retrieval_web_search`: Web Search @@ -233,7 +233,6 @@ interface ScriptRuntimeOptions { * - `fs_read_file`: Reads a file as text from the file system. * - `fs_read_summary`: Reads a summary of a file from the file system. * - `math_eval`: Evaluates a math expression -* - `python_interpreter`: Executes python 3.12 code in a docker container. The process output is returned. Use 'print' to output data. * - `retrieval_fuzz_search`: Search for keywords using the full text of files and a fuzzy distance. * - `retrieval_vector_search`: Search files using embeddings and similarity distance. * - `retrieval_web_search`: Search the web for a user query using Bing Search. @@ -1631,6 +1630,11 @@ interface ContainerHost extends ShellHost { * Stops and cleans out the container */ stop(): Promise + + /** + * Force disconnect network + */ + disconnect(): Promise } interface PromptContext extends ChatGenerationContext { diff --git a/packages/sample/genaisrc/style/genaiscript.d.ts b/packages/sample/genaisrc/style/genaiscript.d.ts index 8fccf3c5fa..3f0a6543c7 100644 --- a/packages/sample/genaisrc/style/genaiscript.d.ts +++ b/packages/sample/genaisrc/style/genaiscript.d.ts @@ -67,9 +67,9 @@ interface PromptLike extends PromptDefinition { text?: string } -type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> +type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_code_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> -type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "python_interpreter" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> +type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> type FileMergeHandler = ( filename: string, @@ -212,7 +212,7 @@ interface ScriptRuntimeOptions { * - `system.functions`: use functions * - `system.math`: Math expression evaluator * - `system.python`: Expert at generating and understanding Python code. -* - `system.python_interpreter`: Python Dockerized code execution +* - `system.python_code_interpreter`: Python Dockerized code execution for data analysis * - `system.retrieval_fuzz_search`: Full Text Fuzzy Search * - `system.retrieval_vector_search`: Embeddings Vector Search * - `system.retrieval_web_search`: Web Search @@ -233,7 +233,6 @@ interface ScriptRuntimeOptions { * - `fs_read_file`: Reads a file as text from the file system. * - `fs_read_summary`: Reads a summary of a file from the file system. * - `math_eval`: Evaluates a math expression -* - `python_interpreter`: Executes python 3.12 code in a docker container. The process output is returned. Use 'print' to output data. * - `retrieval_fuzz_search`: Search for keywords using the full text of files and a fuzzy distance. * - `retrieval_vector_search`: Search files using embeddings and similarity distance. * - `retrieval_web_search`: Search the web for a user query using Bing Search. @@ -1631,6 +1630,11 @@ interface ContainerHost extends ShellHost { * Stops and cleans out the container */ stop(): Promise + + /** + * Force disconnect network + */ + disconnect(): Promise } interface PromptContext extends ChatGenerationContext { diff --git a/packages/sample/src/aici/genaiscript.d.ts b/packages/sample/src/aici/genaiscript.d.ts index 8fccf3c5fa..3f0a6543c7 100644 --- a/packages/sample/src/aici/genaiscript.d.ts +++ b/packages/sample/src/aici/genaiscript.d.ts @@ -67,9 +67,9 @@ interface PromptLike extends PromptDefinition { text?: string } -type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> +type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_code_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> -type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "python_interpreter" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> +type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> type FileMergeHandler = ( filename: string, @@ -212,7 +212,7 @@ interface ScriptRuntimeOptions { * - `system.functions`: use functions * - `system.math`: Math expression evaluator * - `system.python`: Expert at generating and understanding Python code. -* - `system.python_interpreter`: Python Dockerized code execution +* - `system.python_code_interpreter`: Python Dockerized code execution for data analysis * - `system.retrieval_fuzz_search`: Full Text Fuzzy Search * - `system.retrieval_vector_search`: Embeddings Vector Search * - `system.retrieval_web_search`: Web Search @@ -233,7 +233,6 @@ interface ScriptRuntimeOptions { * - `fs_read_file`: Reads a file as text from the file system. * - `fs_read_summary`: Reads a summary of a file from the file system. * - `math_eval`: Evaluates a math expression -* - `python_interpreter`: Executes python 3.12 code in a docker container. The process output is returned. Use 'print' to output data. * - `retrieval_fuzz_search`: Search for keywords using the full text of files and a fuzzy distance. * - `retrieval_vector_search`: Search files using embeddings and similarity distance. * - `retrieval_web_search`: Search the web for a user query using Bing Search. @@ -1631,6 +1630,11 @@ interface ContainerHost extends ShellHost { * Stops and cleans out the container */ stop(): Promise + + /** + * Force disconnect network + */ + disconnect(): Promise } interface PromptContext extends ChatGenerationContext { diff --git a/packages/sample/src/errors/genaiscript.d.ts b/packages/sample/src/errors/genaiscript.d.ts index 8fccf3c5fa..3f0a6543c7 100644 --- a/packages/sample/src/errors/genaiscript.d.ts +++ b/packages/sample/src/errors/genaiscript.d.ts @@ -67,9 +67,9 @@ interface PromptLike extends PromptDefinition { text?: string } -type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> +type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_code_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> -type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "python_interpreter" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> +type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> type FileMergeHandler = ( filename: string, @@ -212,7 +212,7 @@ interface ScriptRuntimeOptions { * - `system.functions`: use functions * - `system.math`: Math expression evaluator * - `system.python`: Expert at generating and understanding Python code. -* - `system.python_interpreter`: Python Dockerized code execution +* - `system.python_code_interpreter`: Python Dockerized code execution for data analysis * - `system.retrieval_fuzz_search`: Full Text Fuzzy Search * - `system.retrieval_vector_search`: Embeddings Vector Search * - `system.retrieval_web_search`: Web Search @@ -233,7 +233,6 @@ interface ScriptRuntimeOptions { * - `fs_read_file`: Reads a file as text from the file system. * - `fs_read_summary`: Reads a summary of a file from the file system. * - `math_eval`: Evaluates a math expression -* - `python_interpreter`: Executes python 3.12 code in a docker container. The process output is returned. Use 'print' to output data. * - `retrieval_fuzz_search`: Search for keywords using the full text of files and a fuzzy distance. * - `retrieval_vector_search`: Search files using embeddings and similarity distance. * - `retrieval_web_search`: Search the web for a user query using Bing Search. @@ -1631,6 +1630,11 @@ interface ContainerHost extends ShellHost { * Stops and cleans out the container */ stop(): Promise + + /** + * Force disconnect network + */ + disconnect(): Promise } interface PromptContext extends ChatGenerationContext { diff --git a/packages/sample/src/makecode/genaiscript.d.ts b/packages/sample/src/makecode/genaiscript.d.ts index 8fccf3c5fa..3f0a6543c7 100644 --- a/packages/sample/src/makecode/genaiscript.d.ts +++ b/packages/sample/src/makecode/genaiscript.d.ts @@ -67,9 +67,9 @@ interface PromptLike extends PromptDefinition { text?: string } -type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> +type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_code_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> -type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "python_interpreter" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> +type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> type FileMergeHandler = ( filename: string, @@ -212,7 +212,7 @@ interface ScriptRuntimeOptions { * - `system.functions`: use functions * - `system.math`: Math expression evaluator * - `system.python`: Expert at generating and understanding Python code. -* - `system.python_interpreter`: Python Dockerized code execution +* - `system.python_code_interpreter`: Python Dockerized code execution for data analysis * - `system.retrieval_fuzz_search`: Full Text Fuzzy Search * - `system.retrieval_vector_search`: Embeddings Vector Search * - `system.retrieval_web_search`: Web Search @@ -233,7 +233,6 @@ interface ScriptRuntimeOptions { * - `fs_read_file`: Reads a file as text from the file system. * - `fs_read_summary`: Reads a summary of a file from the file system. * - `math_eval`: Evaluates a math expression -* - `python_interpreter`: Executes python 3.12 code in a docker container. The process output is returned. Use 'print' to output data. * - `retrieval_fuzz_search`: Search for keywords using the full text of files and a fuzzy distance. * - `retrieval_vector_search`: Search files using embeddings and similarity distance. * - `retrieval_web_search`: Search the web for a user query using Bing Search. @@ -1631,6 +1630,11 @@ interface ContainerHost extends ShellHost { * Stops and cleans out the container */ stop(): Promise + + /** + * Force disconnect network + */ + disconnect(): Promise } interface PromptContext extends ChatGenerationContext { diff --git a/packages/sample/src/tla/genaiscript.d.ts b/packages/sample/src/tla/genaiscript.d.ts index 8fccf3c5fa..3f0a6543c7 100644 --- a/packages/sample/src/tla/genaiscript.d.ts +++ b/packages/sample/src/tla/genaiscript.d.ts @@ -67,9 +67,9 @@ interface PromptLike extends PromptDefinition { text?: string } -type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> +type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_code_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> -type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "python_interpreter" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> +type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> type FileMergeHandler = ( filename: string, @@ -212,7 +212,7 @@ interface ScriptRuntimeOptions { * - `system.functions`: use functions * - `system.math`: Math expression evaluator * - `system.python`: Expert at generating and understanding Python code. -* - `system.python_interpreter`: Python Dockerized code execution +* - `system.python_code_interpreter`: Python Dockerized code execution for data analysis * - `system.retrieval_fuzz_search`: Full Text Fuzzy Search * - `system.retrieval_vector_search`: Embeddings Vector Search * - `system.retrieval_web_search`: Web Search @@ -233,7 +233,6 @@ interface ScriptRuntimeOptions { * - `fs_read_file`: Reads a file as text from the file system. * - `fs_read_summary`: Reads a summary of a file from the file system. * - `math_eval`: Evaluates a math expression -* - `python_interpreter`: Executes python 3.12 code in a docker container. The process output is returned. Use 'print' to output data. * - `retrieval_fuzz_search`: Search for keywords using the full text of files and a fuzzy distance. * - `retrieval_vector_search`: Search files using embeddings and similarity distance. * - `retrieval_web_search`: Search the web for a user query using Bing Search. @@ -1631,6 +1630,11 @@ interface ContainerHost extends ShellHost { * Stops and cleans out the container */ stop(): Promise + + /** + * Force disconnect network + */ + disconnect(): Promise } interface PromptContext extends ChatGenerationContext { diff --git a/packages/sample/src/vision/genaiscript.d.ts b/packages/sample/src/vision/genaiscript.d.ts index 8fccf3c5fa..3f0a6543c7 100644 --- a/packages/sample/src/vision/genaiscript.d.ts +++ b/packages/sample/src/vision/genaiscript.d.ts @@ -67,9 +67,9 @@ interface PromptLike extends PromptDefinition { text?: string } -type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> +type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_code_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> -type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "python_interpreter" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> +type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> type FileMergeHandler = ( filename: string, @@ -212,7 +212,7 @@ interface ScriptRuntimeOptions { * - `system.functions`: use functions * - `system.math`: Math expression evaluator * - `system.python`: Expert at generating and understanding Python code. -* - `system.python_interpreter`: Python Dockerized code execution +* - `system.python_code_interpreter`: Python Dockerized code execution for data analysis * - `system.retrieval_fuzz_search`: Full Text Fuzzy Search * - `system.retrieval_vector_search`: Embeddings Vector Search * - `system.retrieval_web_search`: Web Search @@ -233,7 +233,6 @@ interface ScriptRuntimeOptions { * - `fs_read_file`: Reads a file as text from the file system. * - `fs_read_summary`: Reads a summary of a file from the file system. * - `math_eval`: Evaluates a math expression -* - `python_interpreter`: Executes python 3.12 code in a docker container. The process output is returned. Use 'print' to output data. * - `retrieval_fuzz_search`: Search for keywords using the full text of files and a fuzzy distance. * - `retrieval_vector_search`: Search files using embeddings and similarity distance. * - `retrieval_web_search`: Search the web for a user query using Bing Search. @@ -1631,6 +1630,11 @@ interface ContainerHost extends ShellHost { * Stops and cleans out the container */ stop(): Promise + + /** + * Force disconnect network + */ + disconnect(): Promise } interface PromptContext extends ChatGenerationContext { diff --git a/slides/genaisrc/genaiscript.d.ts b/slides/genaisrc/genaiscript.d.ts index 8fccf3c5fa..3f0a6543c7 100644 --- a/slides/genaisrc/genaiscript.d.ts +++ b/slides/genaisrc/genaiscript.d.ts @@ -67,9 +67,9 @@ interface PromptLike extends PromptDefinition { text?: string } -type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> +type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_code_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> -type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "python_interpreter" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> +type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> type FileMergeHandler = ( filename: string, @@ -212,7 +212,7 @@ interface ScriptRuntimeOptions { * - `system.functions`: use functions * - `system.math`: Math expression evaluator * - `system.python`: Expert at generating and understanding Python code. -* - `system.python_interpreter`: Python Dockerized code execution +* - `system.python_code_interpreter`: Python Dockerized code execution for data analysis * - `system.retrieval_fuzz_search`: Full Text Fuzzy Search * - `system.retrieval_vector_search`: Embeddings Vector Search * - `system.retrieval_web_search`: Web Search @@ -233,7 +233,6 @@ interface ScriptRuntimeOptions { * - `fs_read_file`: Reads a file as text from the file system. * - `fs_read_summary`: Reads a summary of a file from the file system. * - `math_eval`: Evaluates a math expression -* - `python_interpreter`: Executes python 3.12 code in a docker container. The process output is returned. Use 'print' to output data. * - `retrieval_fuzz_search`: Search for keywords using the full text of files and a fuzzy distance. * - `retrieval_vector_search`: Search files using embeddings and similarity distance. * - `retrieval_web_search`: Search the web for a user query using Bing Search. @@ -1631,6 +1630,11 @@ interface ContainerHost extends ShellHost { * Stops and cleans out the container */ stop(): Promise + + /** + * Force disconnect network + */ + disconnect(): Promise } interface PromptContext extends ChatGenerationContext { From 64732cccfdfa1a6ed7738d9d92cc40f55bea5d74 Mon Sep 17 00:00:00 2001 From: pelikhan Date: Wed, 14 Aug 2024 10:13:05 -0700 Subject: [PATCH 2/5] fix system parsing --- docs/genaisrc/genaiscript.d.ts | 3 ++- docs/src/components/BuiltinTools.mdx | 1 + docs/src/content/docs/reference/scripts/system.mdx | 8 ++------ genaisrc/genaiscript.d.ts | 3 ++- packages/cli/src/docker.ts | 11 ++++++++--- packages/core/src/genaisrc/genaiscript.d.ts | 3 ++- .../genaisrc/system.python_code_interpreter.genai.js | 7 +------ packages/sample/genaisrc/container.genai.mjs | 8 ++++++-- packages/sample/genaisrc/genaiscript.d.ts | 3 ++- packages/sample/genaisrc/node/genaiscript.d.ts | 3 ++- packages/sample/genaisrc/python/genaiscript.d.ts | 3 ++- packages/sample/genaisrc/style/genaiscript.d.ts | 3 ++- packages/sample/src/aici/genaiscript.d.ts | 3 ++- packages/sample/src/errors/genaiscript.d.ts | 3 ++- packages/sample/src/makecode/genaiscript.d.ts | 3 ++- packages/sample/src/tla/genaiscript.d.ts | 3 ++- packages/sample/src/vision/genaiscript.d.ts | 3 ++- slides/genaisrc/genaiscript.d.ts | 3 ++- 18 files changed, 44 insertions(+), 30 deletions(-) diff --git a/docs/genaisrc/genaiscript.d.ts b/docs/genaisrc/genaiscript.d.ts index 3f0a6543c7..51ae8b5f0f 100644 --- a/docs/genaisrc/genaiscript.d.ts +++ b/docs/genaisrc/genaiscript.d.ts @@ -69,7 +69,7 @@ interface PromptLike extends PromptDefinition { type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_code_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> -type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> +type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "python_code_interpreter" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> type FileMergeHandler = ( filename: string, @@ -233,6 +233,7 @@ interface ScriptRuntimeOptions { * - `fs_read_file`: Reads a file as text from the file system. * - `fs_read_summary`: Reads a summary of a file from the file system. * - `math_eval`: Evaluates a math expression +* - `python_code_interpreter`: Executes python 3.12 code for Data Analysis tasks in a docker container. The process output is returned. Do not generate visualizations. The only packages available are numpy, pandas, scipy. There is NO network connectivity. Do not attempt to install other packages or make web requests. * - `retrieval_fuzz_search`: Search for keywords using the full text of files and a fuzzy distance. * - `retrieval_vector_search`: Search files using embeddings and similarity distance. * - `retrieval_web_search`: Search the web for a user query using Bing Search. diff --git a/docs/src/components/BuiltinTools.mdx b/docs/src/components/BuiltinTools.mdx index acd6b4c9fc..059f8a69ce 100644 --- a/docs/src/components/BuiltinTools.mdx +++ b/docs/src/components/BuiltinTools.mdx @@ -10,6 +10,7 @@ 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 8f6c1655c1..1633639664 100644 --- a/docs/src/content/docs/reference/scripts/system.mdx +++ b/docs/src/content/docs/reference/scripts/system.mdx @@ -596,7 +596,7 @@ Python Dockerized code execution for data analysis - +- tool `python_code_interpreter`: Executes python 3.12 code for Data Analysis tasks in a docker container. The process output is returned. Do not generate visualizations. The only packages available are numpy, pandas, scipy. There is NO network connectivity. Do not attempt to install other packages or make web requests. `````js wrap title="system.python_code_interpreter" system({ @@ -610,11 +610,7 @@ let container = null defTool( "python_code_interpreter", - `Executes python 3.12 code for Data Analysis tasks in a docker container. -- The process output is returned. -- Do not generate visualizations. -- The only packages available are ${packages.join(", ")}. -- There is NO network connectivity. Do not attempt to install other packages or make web requests.`, + "Executes python 3.12 code for Data Analysis tasks in a docker container. The process output is returned. Do not generate visualizations. The only packages available are numpy, pandas, scipy. There is NO network connectivity. Do not attempt to install other packages or make web requests.", { type: "object", properties: { diff --git a/genaisrc/genaiscript.d.ts b/genaisrc/genaiscript.d.ts index 3f0a6543c7..51ae8b5f0f 100644 --- a/genaisrc/genaiscript.d.ts +++ b/genaisrc/genaiscript.d.ts @@ -69,7 +69,7 @@ interface PromptLike extends PromptDefinition { type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_code_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> -type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> +type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "python_code_interpreter" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> type FileMergeHandler = ( filename: string, @@ -233,6 +233,7 @@ interface ScriptRuntimeOptions { * - `fs_read_file`: Reads a file as text from the file system. * - `fs_read_summary`: Reads a summary of a file from the file system. * - `math_eval`: Evaluates a math expression +* - `python_code_interpreter`: Executes python 3.12 code for Data Analysis tasks in a docker container. The process output is returned. Do not generate visualizations. The only packages available are numpy, pandas, scipy. There is NO network connectivity. Do not attempt to install other packages or make web requests. * - `retrieval_fuzz_search`: Search for keywords using the full text of files and a fuzzy distance. * - `retrieval_vector_search`: Search files using embeddings and similarity distance. * - `retrieval_web_search`: Search the web for a user query using Bing Search. diff --git a/packages/cli/src/docker.ts b/packages/cli/src/docker.ts index 3e4b570041..aa32eff929 100644 --- a/packages/cli/src/docker.ts +++ b/packages/cli/src/docker.ts @@ -302,11 +302,16 @@ export class DockerManager { const disconnect = async () => { const networks = await this._docker.listNetworks() for (const network of networks.filter( - (n) => n.Name !== "bridge" + ({ Name }) => Name === "bridge" )) { - console.log(`container: disconnect ${network.Name}`) const n = await this._docker.getNetwork(network.Id) - if (n) await n.disconnect({ Container: container.id }) + if (n) { + const state = await n.inspect() + if (state?.Containers?.[container.id]) { + console.log(`container: disconnect ${network.Name}`) + await n.disconnect({ Container: container.id }) + } + } } } diff --git a/packages/core/src/genaisrc/genaiscript.d.ts b/packages/core/src/genaisrc/genaiscript.d.ts index 3f0a6543c7..51ae8b5f0f 100644 --- a/packages/core/src/genaisrc/genaiscript.d.ts +++ b/packages/core/src/genaisrc/genaiscript.d.ts @@ -69,7 +69,7 @@ interface PromptLike extends PromptDefinition { type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_code_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> -type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> +type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "python_code_interpreter" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> type FileMergeHandler = ( filename: string, @@ -233,6 +233,7 @@ interface ScriptRuntimeOptions { * - `fs_read_file`: Reads a file as text from the file system. * - `fs_read_summary`: Reads a summary of a file from the file system. * - `math_eval`: Evaluates a math expression +* - `python_code_interpreter`: Executes python 3.12 code for Data Analysis tasks in a docker container. The process output is returned. Do not generate visualizations. The only packages available are numpy, pandas, scipy. There is NO network connectivity. Do not attempt to install other packages or make web requests. * - `retrieval_fuzz_search`: Search for keywords using the full text of files and a fuzzy distance. * - `retrieval_vector_search`: Search files using embeddings and similarity distance. * - `retrieval_web_search`: Search the web for a user query using Bing Search. diff --git a/packages/core/src/genaisrc/system.python_code_interpreter.genai.js b/packages/core/src/genaisrc/system.python_code_interpreter.genai.js index f7d4ae75c0..3c769ca6e3 100644 --- a/packages/core/src/genaisrc/system.python_code_interpreter.genai.js +++ b/packages/core/src/genaisrc/system.python_code_interpreter.genai.js @@ -9,11 +9,7 @@ let container = null defTool( "python_code_interpreter", - `Executes python 3.12 code for Data Analysis tasks in a docker container. -- The process output is returned. -- Do not generate visualizations. -- The only packages available are ${packages.join(", ")}. -- There is NO network connectivity. Do not attempt to install other packages or make web requests.`, + "Executes python 3.12 code for Data Analysis tasks in a docker container. The process output is returned. Do not generate visualizations. The only packages available are numpy, pandas, scipy. There is NO network connectivity. Do not attempt to install other packages or make web requests.", { type: "object", properties: { @@ -30,7 +26,6 @@ defTool( if (!container) { console.log(`python: preparing container...`) container = await host.container({ image, networkEnabled: true }) - await container.disconnect() const res = await container.exec("pip", [ "install", "--root-user-action", diff --git a/packages/sample/genaisrc/container.genai.mjs b/packages/sample/genaisrc/container.genai.mjs index 787adc0974..c2d3c5a9b5 100644 --- a/packages/sample/genaisrc/container.genai.mjs +++ b/packages/sample/genaisrc/container.genai.mjs @@ -6,10 +6,13 @@ script({ }) const disablePurge = env.vars.purge === "no" -const container = await host.container({ disablePurge }) +const container = await host.container({ disablePurge, networkEnabled: true }) const version = await container.exec("python", ["--version"]) if (!/^python \d/i.test(version.stdout)) throw new Error("python --version failed") +await container.disconnect() +const pipfailed = await container.exec("pip", ["install", "pandas"]) +if (!pipfailed.failed) throw new Error("network not disconnected") await container.writeText("pythonversion.txt", version.stdout) const fversion = await container.readText("pythonversion.txt") if (version.stdout !== fversion) @@ -17,7 +20,8 @@ if (version.stdout !== fversion) `writetext/readtext error, expected '${version.stdout}', got '${fversion}'` ) await container.copyTo("src/rag/*", "copied") -if (!await container.readText("copied/src/rag/markdown.md")) throw new Error("copy failed") +if (!(await container.readText("copied/src/rag/markdown.md"))) + throw new Error("copy failed") await container.writeText("main.py", 'print("hello")') const hello = await container.exec("python", ["main.py"]) if (hello.exitCode) throw new Error("python script failed") diff --git a/packages/sample/genaisrc/genaiscript.d.ts b/packages/sample/genaisrc/genaiscript.d.ts index 3f0a6543c7..51ae8b5f0f 100644 --- a/packages/sample/genaisrc/genaiscript.d.ts +++ b/packages/sample/genaisrc/genaiscript.d.ts @@ -69,7 +69,7 @@ interface PromptLike extends PromptDefinition { type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_code_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> -type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> +type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "python_code_interpreter" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> type FileMergeHandler = ( filename: string, @@ -233,6 +233,7 @@ interface ScriptRuntimeOptions { * - `fs_read_file`: Reads a file as text from the file system. * - `fs_read_summary`: Reads a summary of a file from the file system. * - `math_eval`: Evaluates a math expression +* - `python_code_interpreter`: Executes python 3.12 code for Data Analysis tasks in a docker container. The process output is returned. Do not generate visualizations. The only packages available are numpy, pandas, scipy. There is NO network connectivity. Do not attempt to install other packages or make web requests. * - `retrieval_fuzz_search`: Search for keywords using the full text of files and a fuzzy distance. * - `retrieval_vector_search`: Search files using embeddings and similarity distance. * - `retrieval_web_search`: Search the web for a user query using Bing Search. diff --git a/packages/sample/genaisrc/node/genaiscript.d.ts b/packages/sample/genaisrc/node/genaiscript.d.ts index 3f0a6543c7..51ae8b5f0f 100644 --- a/packages/sample/genaisrc/node/genaiscript.d.ts +++ b/packages/sample/genaisrc/node/genaiscript.d.ts @@ -69,7 +69,7 @@ interface PromptLike extends PromptDefinition { type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_code_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> -type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> +type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "python_code_interpreter" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> type FileMergeHandler = ( filename: string, @@ -233,6 +233,7 @@ interface ScriptRuntimeOptions { * - `fs_read_file`: Reads a file as text from the file system. * - `fs_read_summary`: Reads a summary of a file from the file system. * - `math_eval`: Evaluates a math expression +* - `python_code_interpreter`: Executes python 3.12 code for Data Analysis tasks in a docker container. The process output is returned. Do not generate visualizations. The only packages available are numpy, pandas, scipy. There is NO network connectivity. Do not attempt to install other packages or make web requests. * - `retrieval_fuzz_search`: Search for keywords using the full text of files and a fuzzy distance. * - `retrieval_vector_search`: Search files using embeddings and similarity distance. * - `retrieval_web_search`: Search the web for a user query using Bing Search. diff --git a/packages/sample/genaisrc/python/genaiscript.d.ts b/packages/sample/genaisrc/python/genaiscript.d.ts index 3f0a6543c7..51ae8b5f0f 100644 --- a/packages/sample/genaisrc/python/genaiscript.d.ts +++ b/packages/sample/genaisrc/python/genaiscript.d.ts @@ -69,7 +69,7 @@ interface PromptLike extends PromptDefinition { type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_code_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> -type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> +type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "python_code_interpreter" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> type FileMergeHandler = ( filename: string, @@ -233,6 +233,7 @@ interface ScriptRuntimeOptions { * - `fs_read_file`: Reads a file as text from the file system. * - `fs_read_summary`: Reads a summary of a file from the file system. * - `math_eval`: Evaluates a math expression +* - `python_code_interpreter`: Executes python 3.12 code for Data Analysis tasks in a docker container. The process output is returned. Do not generate visualizations. The only packages available are numpy, pandas, scipy. There is NO network connectivity. Do not attempt to install other packages or make web requests. * - `retrieval_fuzz_search`: Search for keywords using the full text of files and a fuzzy distance. * - `retrieval_vector_search`: Search files using embeddings and similarity distance. * - `retrieval_web_search`: Search the web for a user query using Bing Search. diff --git a/packages/sample/genaisrc/style/genaiscript.d.ts b/packages/sample/genaisrc/style/genaiscript.d.ts index 3f0a6543c7..51ae8b5f0f 100644 --- a/packages/sample/genaisrc/style/genaiscript.d.ts +++ b/packages/sample/genaisrc/style/genaiscript.d.ts @@ -69,7 +69,7 @@ interface PromptLike extends PromptDefinition { type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_code_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> -type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> +type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "python_code_interpreter" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> type FileMergeHandler = ( filename: string, @@ -233,6 +233,7 @@ interface ScriptRuntimeOptions { * - `fs_read_file`: Reads a file as text from the file system. * - `fs_read_summary`: Reads a summary of a file from the file system. * - `math_eval`: Evaluates a math expression +* - `python_code_interpreter`: Executes python 3.12 code for Data Analysis tasks in a docker container. The process output is returned. Do not generate visualizations. The only packages available are numpy, pandas, scipy. There is NO network connectivity. Do not attempt to install other packages or make web requests. * - `retrieval_fuzz_search`: Search for keywords using the full text of files and a fuzzy distance. * - `retrieval_vector_search`: Search files using embeddings and similarity distance. * - `retrieval_web_search`: Search the web for a user query using Bing Search. diff --git a/packages/sample/src/aici/genaiscript.d.ts b/packages/sample/src/aici/genaiscript.d.ts index 3f0a6543c7..51ae8b5f0f 100644 --- a/packages/sample/src/aici/genaiscript.d.ts +++ b/packages/sample/src/aici/genaiscript.d.ts @@ -69,7 +69,7 @@ interface PromptLike extends PromptDefinition { type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_code_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> -type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> +type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "python_code_interpreter" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> type FileMergeHandler = ( filename: string, @@ -233,6 +233,7 @@ interface ScriptRuntimeOptions { * - `fs_read_file`: Reads a file as text from the file system. * - `fs_read_summary`: Reads a summary of a file from the file system. * - `math_eval`: Evaluates a math expression +* - `python_code_interpreter`: Executes python 3.12 code for Data Analysis tasks in a docker container. The process output is returned. Do not generate visualizations. The only packages available are numpy, pandas, scipy. There is NO network connectivity. Do not attempt to install other packages or make web requests. * - `retrieval_fuzz_search`: Search for keywords using the full text of files and a fuzzy distance. * - `retrieval_vector_search`: Search files using embeddings and similarity distance. * - `retrieval_web_search`: Search the web for a user query using Bing Search. diff --git a/packages/sample/src/errors/genaiscript.d.ts b/packages/sample/src/errors/genaiscript.d.ts index 3f0a6543c7..51ae8b5f0f 100644 --- a/packages/sample/src/errors/genaiscript.d.ts +++ b/packages/sample/src/errors/genaiscript.d.ts @@ -69,7 +69,7 @@ interface PromptLike extends PromptDefinition { type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_code_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> -type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> +type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "python_code_interpreter" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> type FileMergeHandler = ( filename: string, @@ -233,6 +233,7 @@ interface ScriptRuntimeOptions { * - `fs_read_file`: Reads a file as text from the file system. * - `fs_read_summary`: Reads a summary of a file from the file system. * - `math_eval`: Evaluates a math expression +* - `python_code_interpreter`: Executes python 3.12 code for Data Analysis tasks in a docker container. The process output is returned. Do not generate visualizations. The only packages available are numpy, pandas, scipy. There is NO network connectivity. Do not attempt to install other packages or make web requests. * - `retrieval_fuzz_search`: Search for keywords using the full text of files and a fuzzy distance. * - `retrieval_vector_search`: Search files using embeddings and similarity distance. * - `retrieval_web_search`: Search the web for a user query using Bing Search. diff --git a/packages/sample/src/makecode/genaiscript.d.ts b/packages/sample/src/makecode/genaiscript.d.ts index 3f0a6543c7..51ae8b5f0f 100644 --- a/packages/sample/src/makecode/genaiscript.d.ts +++ b/packages/sample/src/makecode/genaiscript.d.ts @@ -69,7 +69,7 @@ interface PromptLike extends PromptDefinition { type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_code_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> -type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> +type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "python_code_interpreter" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> type FileMergeHandler = ( filename: string, @@ -233,6 +233,7 @@ interface ScriptRuntimeOptions { * - `fs_read_file`: Reads a file as text from the file system. * - `fs_read_summary`: Reads a summary of a file from the file system. * - `math_eval`: Evaluates a math expression +* - `python_code_interpreter`: Executes python 3.12 code for Data Analysis tasks in a docker container. The process output is returned. Do not generate visualizations. The only packages available are numpy, pandas, scipy. There is NO network connectivity. Do not attempt to install other packages or make web requests. * - `retrieval_fuzz_search`: Search for keywords using the full text of files and a fuzzy distance. * - `retrieval_vector_search`: Search files using embeddings and similarity distance. * - `retrieval_web_search`: Search the web for a user query using Bing Search. diff --git a/packages/sample/src/tla/genaiscript.d.ts b/packages/sample/src/tla/genaiscript.d.ts index 3f0a6543c7..51ae8b5f0f 100644 --- a/packages/sample/src/tla/genaiscript.d.ts +++ b/packages/sample/src/tla/genaiscript.d.ts @@ -69,7 +69,7 @@ interface PromptLike extends PromptDefinition { type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_code_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> -type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> +type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "python_code_interpreter" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> type FileMergeHandler = ( filename: string, @@ -233,6 +233,7 @@ interface ScriptRuntimeOptions { * - `fs_read_file`: Reads a file as text from the file system. * - `fs_read_summary`: Reads a summary of a file from the file system. * - `math_eval`: Evaluates a math expression +* - `python_code_interpreter`: Executes python 3.12 code for Data Analysis tasks in a docker container. The process output is returned. Do not generate visualizations. The only packages available are numpy, pandas, scipy. There is NO network connectivity. Do not attempt to install other packages or make web requests. * - `retrieval_fuzz_search`: Search for keywords using the full text of files and a fuzzy distance. * - `retrieval_vector_search`: Search files using embeddings and similarity distance. * - `retrieval_web_search`: Search the web for a user query using Bing Search. diff --git a/packages/sample/src/vision/genaiscript.d.ts b/packages/sample/src/vision/genaiscript.d.ts index 3f0a6543c7..51ae8b5f0f 100644 --- a/packages/sample/src/vision/genaiscript.d.ts +++ b/packages/sample/src/vision/genaiscript.d.ts @@ -69,7 +69,7 @@ interface PromptLike extends PromptDefinition { type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_code_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> -type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> +type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "python_code_interpreter" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> type FileMergeHandler = ( filename: string, @@ -233,6 +233,7 @@ interface ScriptRuntimeOptions { * - `fs_read_file`: Reads a file as text from the file system. * - `fs_read_summary`: Reads a summary of a file from the file system. * - `math_eval`: Evaluates a math expression +* - `python_code_interpreter`: Executes python 3.12 code for Data Analysis tasks in a docker container. The process output is returned. Do not generate visualizations. The only packages available are numpy, pandas, scipy. There is NO network connectivity. Do not attempt to install other packages or make web requests. * - `retrieval_fuzz_search`: Search for keywords using the full text of files and a fuzzy distance. * - `retrieval_vector_search`: Search files using embeddings and similarity distance. * - `retrieval_web_search`: Search the web for a user query using Bing Search. diff --git a/slides/genaisrc/genaiscript.d.ts b/slides/genaisrc/genaiscript.d.ts index 3f0a6543c7..51ae8b5f0f 100644 --- a/slides/genaisrc/genaiscript.d.ts +++ b/slides/genaisrc/genaiscript.d.ts @@ -69,7 +69,7 @@ interface PromptLike extends PromptDefinition { type SystemPromptId = OptionsOrString<"system" | "system.annotations" | "system.changelog" | "system.diagrams" | "system.diff" | "system.explanations" | "system.files" | "system.files_schema" | "system.fs_find_files" | "system.fs_read_file" | "system.fs_read_summary" | "system.functions" | "system.math" | "system.python" | "system.python_code_interpreter" | "system.retrieval_fuzz_search" | "system.retrieval_vector_search" | "system.retrieval_web_search" | "system.schema" | "system.tasks" | "system.technical" | "system.typescript" | "system.zero_shot_cot"> -type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> +type SystemToolId = OptionsOrString<"fs_find_files" | "fs_read_file" | "fs_read_summary" | "math_eval" | "python_code_interpreter" | "retrieval_fuzz_search" | "retrieval_vector_search" | "retrieval_web_search"> type FileMergeHandler = ( filename: string, @@ -233,6 +233,7 @@ interface ScriptRuntimeOptions { * - `fs_read_file`: Reads a file as text from the file system. * - `fs_read_summary`: Reads a summary of a file from the file system. * - `math_eval`: Evaluates a math expression +* - `python_code_interpreter`: Executes python 3.12 code for Data Analysis tasks in a docker container. The process output is returned. Do not generate visualizations. The only packages available are numpy, pandas, scipy. There is NO network connectivity. Do not attempt to install other packages or make web requests. * - `retrieval_fuzz_search`: Search for keywords using the full text of files and a fuzzy distance. * - `retrieval_vector_search`: Search files using embeddings and similarity distance. * - `retrieval_web_search`: Search the web for a user query using Bing Search. From e9904ff9de5a8776bdbeb6214f2ed5f155d6b461 Mon Sep 17 00:00:00 2001 From: pelikhan Date: Wed, 14 Aug 2024 10:15:04 -0700 Subject: [PATCH 3/5] simplify data-analyst --- packages/sample/genaisrc/data-analyst.genai.mjs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/sample/genaisrc/data-analyst.genai.mjs b/packages/sample/genaisrc/data-analyst.genai.mjs index 2288a64781..03c7fce2c4 100644 --- a/packages/sample/genaisrc/data-analyst.genai.mjs +++ b/packages/sample/genaisrc/data-analyst.genai.mjs @@ -6,8 +6,4 @@ script({ const data = def("DATA", env.files, { sliceSample: 25 }) -$`Analyze ${data} with a detailed statistical analysis. - -- Do not generate visualizations. -- Validate computations with code. -` +$`Analyze ${data} with a detailed statistical analysis.` From 67a4a33cb9eca2d4b0260655d689e5725f8d78fe Mon Sep 17 00:00:00 2001 From: pelikhan Date: Wed, 14 Aug 2024 10:16:43 -0700 Subject: [PATCH 4/5] logVerbose --- packages/cli/src/docker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/docker.ts b/packages/cli/src/docker.ts index aa32eff929..db1e2c585b 100644 --- a/packages/cli/src/docker.ts +++ b/packages/cli/src/docker.ts @@ -308,7 +308,7 @@ export class DockerManager { if (n) { const state = await n.inspect() if (state?.Containers?.[container.id]) { - console.log(`container: disconnect ${network.Name}`) + logVerbose(`container: disconnect ${network.Name}`) await n.disconnect({ Container: container.id }) } } From 425d345d00781ae845383d3dfc3188ce593affe6 Mon Sep 17 00:00:00 2001 From: pelikhan Date: Wed, 14 Aug 2024 10:21:47 -0700 Subject: [PATCH 5/5] format output --- packages/sample/genaisrc/data-analyst.genai.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sample/genaisrc/data-analyst.genai.mjs b/packages/sample/genaisrc/data-analyst.genai.mjs index 03c7fce2c4..02c1fbaa08 100644 --- a/packages/sample/genaisrc/data-analyst.genai.mjs +++ b/packages/sample/genaisrc/data-analyst.genai.mjs @@ -6,4 +6,4 @@ script({ const data = def("DATA", env.files, { sliceSample: 25 }) -$`Analyze ${data} with a detailed statistical analysis.` +$`Analyze ${data} with a detailed statistical analysis. Respond with markdown.`