code_manipulation#
Functions#
|
Extracts Python code from a markdown string response. |
|
Given a response from the LLM, extract the code and post-process it, |
|
Formats the given code using ruff. |
|
Given a code string, replace the view_name with a unique name, |
|
Given a code string, extract the view_name from it using AST. |
Module Contents#
- code_manipulation.extract_code_from_response(response: str)[source]#
Extracts Python code from a markdown string response.
- code_manipulation.prepare_code(result: str, data: str | pandas.DataFrame | None, project: mdvtools.mdvproject.MDVProject, log=print, modify_existing_project=False, view_name='default')[source]#
Given a response from the LLM, extract the code and post-process it, attempting to ensure that - parameters are appropriately ordered. - it will not run a server for the project - etc In the longer term, the intention is to move away from this approach, which is liable to break as the template changes, or as soon as it gets into the hands of actual users…
- code_manipulation._lint_code_with_ruff(code: str, log=print)[source]#
Formats the given code using ruff.
- code_manipulation.patch_viewname(code: str, project: mdvtools.mdvproject.MDVProject)[source]#
Given a code string, replace the view_name with a unique name, attempting to escape any quotes that might have been in the original.