-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
isolated python code interpreter #619
Conversation
@@ -10,7 +10,7 @@ import { LinkCard } from '@astrojs/starlight/components'; | |||
<LinkCard title="fs_read_file" description="Reads a file as text from the file system." href="/genaiscript/reference/scripts/system#systemfs_read_file" /> | |||
<LinkCard title="fs_read_summary" description="Reads a summary of a file from the file system." href="/genaiscript/reference/scripts/system#systemfs_read_summary" /> | |||
<LinkCard title="math_eval" description="Evaluates a math expression" href="/genaiscript/reference/scripts/system#systemmath" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The link for the python_code_interpreter
tool needs to be updated to reflect the new tool name.
generated by pr-docs-review-commit
link_update
@@ -590,64 +590,53 @@ Emit type information compatible with PyLance.` | |||
````` | |||
|
|||
|
|||
### `system.python_interpreter` | |||
### `system.python_code_interpreter` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The header should be updated to system.python_code_interpreter
to match the new tool name.
generated by pr-docs-review-commit
header_update
|
||
Python Dockerized code execution | ||
Python Dockerized code execution for data analysis | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description of the tool should be updated to "Executes python 3.12 code for Data Analysis tasks in a docker container."
generated by pr-docs-review-commit
description_update
The changes in the pull request introduce a new Additionally, the Overall, the changes look good. However, there are a few potential functional issues:
Unfortunately, I can't provide a diff as these are logical considerations and would need further information to propose code changes. For these reasons, I would suggest revising the changes before merging. 🚀
|
}) | ||
|
||
const image = env.vars.pythonImage ?? "python:3.12" | ||
const packages = ["numpy", "pandas", "scipy"] | ||
|
||
let container = null | ||
|
||
defTool( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tool name in the definition should be updated to python_code_interpreter
.
generated by pr-docs-review-commit
tool_name_update
<package1> | ||
<package2> | ||
`, | ||
}, | ||
main: { | ||
type: "string", | ||
description: "python 3.12 source code to execute", | ||
}, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The requirements
property has been removed and should be updated in the documentation.
generated by pr-docs-review-commit
property_removal
main: { | ||
type: "string", | ||
description: "python 3.12 source code to execute", | ||
}, | ||
}, | ||
required: ["requirements", "main"], | ||
required: ["main"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The required
array should be updated to only include main
since requirements
has been removed.
generated by pr-docs-review-commit
required_update
]) | ||
if (res.failed) throw new Error(`Failed to install requirements`) | ||
await container.disconnect() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The section handling the installation of requirements has been removed and should be updated in the documentation.
generated by pr-docs-review-commit
installation_removal
]) | ||
if (res.failed) throw new Error(`Failed to install requirements`) | ||
await container.disconnect() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The addition of await container.disconnect()
should be documented.
generated by pr-docs-review-commit
disconnect_addition
}) | ||
|
||
const image = env.vars.pythonImage ?? "python:3.12" | ||
const packages = ["numpy", "pandas", "scipy"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The declaration of the packages
constant should be documented, explaining that only numpy, pandas, and scipy are available and no additional packages can be installed.
generated by pr-docs-review-commit
packages_declaration
"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 numpy, pandas, scipy. There is NO network connectivity. Do not attempt to install other packages or make web requests.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tool description should be updated to match the new functionality and limitations of the python_code_interpreter
.
generated by pr-docs-review-commit
tool_description_update
<package1> | ||
<package2> | ||
`, | ||
}, | ||
main: { | ||
type: "string", | ||
description: "python 3.12 source code to execute", | ||
}, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The requirements
field is no longer required and should be removed from the required fields list.
generated by pr-docs-review-commit
required_fields_update
main: { | ||
type: "string", | ||
description: "python 3.12 source code to execute", | ||
}, | ||
}, | ||
required: ["requirements", "main"], | ||
required: ["main"], | ||
}, | ||
async (args) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The handling of the requirements
field should be removed as it is no longer part of the tool's functionality.
generated by pr-docs-review-commit
remove_requirements_handling
]) | ||
if (res.failed) throw new Error(`Failed to install requirements`) | ||
await container.disconnect() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The call to container.disconnect()
should be removed as it may interfere with the execution of the Python code in the container. Containers are typically disconnected after the execution is complete, not before.
generated by pr-docs-review-commit
disconnect_removal
@@ -309,6 +325,7 @@ export class DockerManager { | |||
writeText, | |||
readText, | |||
copyTo, | |||
disconnect, | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The disconnect
function is declared but not used within the DockerManager
class. If this function is not needed, consider removing it to avoid confusion. If it is needed in the future, it can be added back. 😊
generated by pr-review-commit
disconnect_unused
/** | ||
* Force disconnect network | ||
*/ | ||
disconnect(): Promise<void> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The disconnect
function in the ContainerHost
interface is missing a detailed description. Consider adding more information about what the function does, what parameters it takes (if any), and what it returns. This will help other developers understand its purpose more easily. 😊
generated by pr-review-commit
missing_function_description
python_interpreter
tool has been replaced with thepython_code_interpreter
tool specifically for data analysis tasks. 🛠️python_code_interpreter
comes with pre-installed packages - numpy, pandas, scipy - for data analysis tasks. 📊disconnect()
method. 👥data-analyst.genai.mjs
file was updated to use newpython_code_interpreter
instead of the oldpython_interpreter
. 🔄container.genai.mjs
file was updated to test the new disconnection functionality. 🔍