Skip to content

This script leverages OpenAI's ChatGPT to provide assistance in fixing or suggesting solutions for errors in a Python file. It supports two modes of operation: processing the Python code directly or analyzing the output of a Python file via pipe. By interacting with ChatGPT, the script generates suggestions or explanations tailored to the provided.

License

z0m31en7/GPTPythonFixer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GPTPythonFixer


This script leverages OpenAI's ChatGPT to provide assistance in fixing or suggesting solutions for errors in a Python file. It supports two modes of operation: processing the Python code directly or analyzing the output of a Python file via pipe. By interacting with ChatGPT, the script generates suggestions or explanations tailored to the provided Python code or output.



shieldsshieldsshieldsshieldsshieldsshields



💡 Usage:


python GPTPythonFixer.py <file_path> [-p | --pipe]

Arguments:

  • file_path: The path to the Python file to be fixed or analyzed.
  • -p, --pipe: Optional argument. If provided, the script will use the output of the Python file via pipe instead of directly processing the file.


🛠️ Functionality:


  1. Reads the specified Python file or captures the output of a Python file via pipe.
  2. Interacts with ChatGPT to generate suggestions or explanations based on the provided Python code or output.
  3. If operating on the file directly:
    • Prints the suggested code or error explanation.
    • Prompts the user to confirm replacing the code in the file.
    • Replaces the code in the file if the user confirms.
  4. If using the output via pipe:
    • Prints the suggested output based on the ChatGPT response.


🔮 Examples:

  • Process Python file directly: python fix_python_file.py path/to/your/python/file.py

  • Process Python file output via pipe: python error.py | python fix_python_file.py -p


📜 Note:

  • The script requires the OpenAI Python package (openai) to be installed.
  • Replace 'YOUR_API_KEY' with your actual OpenAI API key in the script.
  • Exercise caution when replacing code in a file and perform adequate testing.
  • The script provides a basic example and may not handle all complex code or errors.
  • The changes are suggested by ChatGPT and might contain errors.


🛡️ License:


This project is licensed under the MIT-LICENSE

About

This script leverages OpenAI's ChatGPT to provide assistance in fixing or suggesting solutions for errors in a Python file. It supports two modes of operation: processing the Python code directly or analyzing the output of a Python file via pipe. By interacting with ChatGPT, the script generates suggestions or explanations tailored to the provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages