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

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

Open
endolith opened this issue Sep 26, 2024 · 1 comment
Open

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

endolith opened this issue Sep 26, 2024 · 1 comment
Labels
Enhancement New feature or request

Comments

@endolith
Copy link

endolith commented Sep 26, 2024

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

@bobemoe
Copy link

bobemoe commented Oct 22, 2024

I have similar issue but it is trying to create files using bash cat wheredoc and there is a bug preventing this working. #1485

While your issue with the escaping and my issue with the malformed file should still be resolved seperatly I think direct file access would be a great feature to avoid these kind methods to create a new file.

I'm not sure if your issue is a bug with interpreter or just the ai not getting the code right. Have you tried adding instruction to your prompt on how to create files using correct escaping? I added instruction to mine not to use heredoc so it now avoids that method.

@MikeBirdTech MikeBirdTech added the Enhancement New feature or request label Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants