Skip to main content

A Python library for debugging python files and notebooks using GROQ

Project description

PyDebugger

PyDebuggerTools is a Python library designed to enhance error debugging in both .ipynb and .py scripts. It provides a detailed explanation of errors and suggests possible corrections using the power of LangChain and advanced traceback analysis.

Features

  • Environment-Aware Debugging: Automatically detects whether the code is running in a .py file or a Jupyter Notebook and adapts its behavior accordingly.
  • Error Analysis and Correction: Extracts error details (like line number, file name, and traceback) and generates concise explanations with possible solutions.
  • Code Context Display: For .py files, displays the code context where the error occurred, highlighting the relevant lines.
  • Seamless Integration with LangChain: Uses LangChain's AI capabilities to provide intelligent error solutions.

Installation

Install the package using pip:

pip install PyDebugTools

Usage

Basic Example

from PyDebugTool.debug import PyDebugger

debugger = PyDebugger(langchain_model="llama3-8b-8192", api_key="your_groq_api_key")
debugger.enable()

How It Works

  1. Initialization: Create an instance of PyDebugTool by specifying your LangChain model and API key.
  2. Enable Debugger: Call enable() to activate error handling.
  3. Error Handling: When an error occurs, PyDebugger will intercept it and display detailed insights along with possible fixes.

Detailed Behavior

  • In .ipynb files: Overrides the default IPython traceback display to show enhanced error details and solutions.
  • In .py Scripts: Replaces the default Python exception hook to provide enriched error handling in the console.

Example Code

When an error occurs, PyDebugger might display something like this:

from PyDebugTool.debug import PyDebugger

debugger = PyDebugger(langchain_model="llama3-8b-8192", api_key="your_groq_api_key")
debugger.enable()

import tensorflow as tf
Traceback (most recent call last):
  File "C:\Users\Sambit Mallick\Desktop\mlops\LLM_TOOL_SOFTWARE\test.py", line 6, in <module>
    import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'

┌─────────────────────────────── 🤖 PyDebugger ───────────────────────────────┐
│ The error is caused by the Python interpreter not being able to find the    │
│ TensorFlow module. This is likely because TensorFlow is not installed in    │
│ the Python environment being used to run the script.                        │
│                                                                             │
│ To correct this error, you can install TensorFlow using pip:                │
│                                                                             │
│ `pip install tensorflow`                                                    │
│                                                                             │
│ Alternatively, you can install it using conda if you are using Anaconda:    │
│                                                                             │
│ `conda install tensorflow`                                                  │
└─────────────────────────────────────────────────────────────────────────────┘

Dependencies

  • langchain_groq
  • IPython
  • rich

License

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

Contributing

Contributions are welcome! Please submit issues and pull requests to improve the library.

Author

Sambit Mallick - Feel free to reach out for collaboration or queries.

Acknowledgments

  • Powered by LangChain and Groq LLM.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyDebugTools-0.2.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

PyDebugTools-0.2.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file PyDebugTools-0.2.0.tar.gz.

File metadata

  • Download URL: PyDebugTools-0.2.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.9

File hashes

Hashes for PyDebugTools-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8013cad02c522ee2d6e4e53b4dce538a5a082e44c6afe21891c319777b32aa38
MD5 5080530e992677400d484c391a00e52a
BLAKE2b-256 c1d1d2c86370a708b85d59ee76df54dc03df9232a49a8af670c7933688156529

See more details on using hashes here.

File details

Details for the file PyDebugTools-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: PyDebugTools-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.9

File hashes

Hashes for PyDebugTools-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 77e4bca95449e2ad3dd6be201298c15eb20bbfb75e6b715724249fd977d34b6c
MD5 67126d22a7bc6cefe84cf96b13a4edf8
BLAKE2b-256 f6d15c50366c37d92f539309297479349eb697859cb7fd89d9af7523a4c8be0b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page