Skip to content
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

TLK-2364 - implements preamble extension for python interpreter tool #887

Conversation

EugeneLightsOn
Copy link
Collaborator

@EugeneLightsOn EugeneLightsOn commented Dec 19, 2024

Interpreter Tool Improvements:

  • Set forbidden packages.
  • Add an additional preamble to prevent the use of forbidden packages in generated code.

AI Description

This pull request introduces a new feature to the Python interpreter tool, allowing for the specification of forbidden packages. This enhancement ensures that certain packages are not used during code generation, providing a more controlled and secure environment for code execution.

Summary of Changes:

  • A new field, forbidden_packages, is added to the PythonToolSettings class in src/backend/config/settings.py. This field is an optional list of strings, and it defaults to a list of specific packages that are not allowed to be used in the Python interpreter tool.
  • The BaseToolPreambleRegistry class in src/backend/tools/base.py is renamed to ToolDefaultPreambleRegistry.
  • The preamble for the toolkit_python_interpreter tool is updated to include a list of forbidden packages.
  • The get_preamble method in the ToolDefaultPreambleRegistry class is modified to retrieve the custom preamble for a given tool class, specifically for the toolkit_python_interpreter tool.
  • The get_preamble and set_preamble class methods are added to the BaseTool class to manage the default preamble.

@codecov-commenter
Copy link

codecov-commenter commented Dec 19, 2024

Codecov Report

Attention: Patch coverage is 53.33333% with 14 lines in your changes missing coverage. Please review.

Project coverage is 77.84%. Comparing base (6fc3a08) to head (50d9de9).

Files with missing lines Patch % Lines
src/backend/tools/base.py 51.72% 14 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #887      +/-   ##
==========================================
- Coverage   77.91%   77.84%   -0.08%     
==========================================
  Files         259      259              
  Lines       11150    11176      +26     
==========================================
+ Hits         8688     8700      +12     
- Misses       2462     2476      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@EugeneLightsOn EugeneLightsOn merged commit 131a1a2 into main Dec 23, 2024
8 checks passed
@EugeneLightsOn EugeneLightsOn deleted the eugene1/tlk-2364-make-sure-generated-code-does-not-use-invalid-packages branch December 23, 2024 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants