Skip to content

AI should be able to create files without interpreting Python #1466

@endolith

Description

@endolith

Is your feature request related to a problem? Please describe.

The AI keeps going in circles:

  1. Uses Python interpreter to write code, gets it working
  2. I ask it to write that code to disk for later use.
  3. It uses Python interpreter to write a multiline string containing that python code to a .py file
  4. It screws up the newline escaping, resulting in this error:
      cleaned_coordinates = gps_coordinates.split('
                                                  ^
  SyntaxError: unterminated string literal (detected at line 12)
  1. It uses Python interpreter to look at the file it created:
  It appears that the newline handling issue remains unresolved in the integrated_scraping_and_export.py file. Let's check the contents of
  the file again to identify the exact error and correct it properly. I'll read the file now.



  # Read the contents of the integrated_scraping_and_export.py to check the source for issues
  with open('integrated_scraping_and_export.py', 'r') as file:
      contents = file.read()

  contents
  1. It identifies the escaping error and fixes it.
  I will adjust this line to use the correct escape sequence for the newline character, changing it to:


   cleaned_coordinates = gps_coordinates.split('\\n')[0].strip()
  # Write the fixed integrated script code to the .py file
  with open('integrated_scraping_and_export.py', 'w') as file:
      file.write(final_fixed_full_integrated_script)
  1. It finally works

Describe the solution you'd like

However the AI is able to call commands or call python code (function calling?) should be extended so that it can also read and write files directly, without using the Python interpreter as an intermediate step. Probably should be able to see hex dumps or other representations of files too.

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions