Metadata-Version: 2.1
Name: stochasticparrot
Version: 0.2
Summary: A package for handling errors with custom logging that lets OpenAI API make suggestions.
Home-page: https://github.com/yourusername/custom_error_handler
Author: Wes Ladd
Author-email: wesladd@traingrc.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Description-Content-Type: text/markdown

# Custom Error Handler: Stochastic Parrot

Stochastic Parrot is a Python package that provides a robust way to handle uncaught exceptions in your Python scripts. It logs error details, displays them in a color-coded console output, and leverages OpenAI to suggest fixes.

## Features:

- Colored Console Logging: Utilizes different colors for log levels like DEBUG, INFO, WARNING, ERROR, and CRITICAL.
- File Logging: Automatically logs errors to a file named 'automated_error_handling.log'.
- Traceback Capture: Gathers detailed traceback information including surrounding lines of code where the error occurred.
- OpenAI Integration: Sends error information to OpenAI's GPT-4 model to get suggested fixes.

## How to Use:

1. Installation: Install the package using pip install stochastic-parrot.
2. Initialization: Import and initialize Stochastic Parrot in your script:
   import stochastic_parrot
   stochastic_parrot.initialize()

## Components:

- ColoredConsoleHandler: A custom logging handler class that extends logging.StreamHandler. It allows for log messages to be printed to the console in different colors based on the log level.
- custom_error_handler: A function to be set as sys.excepthook to handle uncaught exceptions. It captures the traceback, reads surrounding code, logs the details, and calls the OpenAI API to suggest fixes.
- openai_chat_completion_base_query: A function to query OpenAI's GPT-4 model. It sends the error details and receives a suggested code fix in response.
- initialize: A function to initialize Stochastic Parrot. It sets up the OpenAI API key and sys.excepthook.

## Requirements:

- openai: To interact with the OpenAI API.
- termcolor: To colorize the console output.
- getpass: To get the OpenAI API key from the user.
- logging: To log the error details.
- sys: To set the custom error handler as sys.excepthook.
- traceback: To capture the traceback.

## License:

This project is licensed under the MIT License. See the LICENSE.txt file for details.
