GithubHelp home page GithubHelp logo

z0m31en7 / gptpythonfixer Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 3.0 8 KB

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: MIT License

Python 100.00%
chatgpt codereview error-handling python

gptpythonfixer's Introduction

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

gptpythonfixer's People

Contributors

z0m31en7 avatar hellblazer767 avatar

Stargazers

tianqi sun avatar hirak0 avatar  avatar Vinícius Bruno avatar  avatar hackerbj avatar  avatar

Watchers

Kostas Georgiou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.