Skip to main content

Translate Python errors into AI-explained suggestions.

Project description

ErrorTranslator

ErrorTranslator is a Python library that translates Python error tracebacks into clear, actionable explanations using AI-powered translation models. It supports multiple backends including OpenAI GPT, HuggingFace models, and local models.


Features

  • Translate Python exceptions into easy-to-understand suggestions.
  • Supports OpenAI GPT, HuggingFace remote models, and local HuggingFace models.
  • Caches translations to avoid repeated API calls.
  • Displays nicely formatted error and translation outputs using Rich.
  • Supports asynchronous translation.

Installation

pip install error_translator

(Replace with actual package name once published)


Requirements

  • Python 3.7+
  • rich
  • python-dotenv
  • Other dependencies depending on model backends (e.g., openai, transformers)

Usage

import os
from error_translator import ErrorTranslator

# Load your OpenAI API key from environment variables
api_key = os.getenv("OPENAI_API_KEY")

translator = ErrorTranslator.with_openai(api_key=api_key)

def buggy_function():
    return 1 / 0

try:
    buggy_function()
except Exception as e:
    translator.translate_error(e)

Available Models

  • ErrorTranslator.with_openai(api_key, model="gpt-4o")
  • ErrorTranslator.with_huggingface(model_name)
  • ErrorTranslator.with_local_huggingface(directory_path)
  • ErrorTranslator.with_custom_model(custom_model_instance)

Environment Variables

Create a .env file in your project root with:

OPENAI_API_KEY=your_openai_api_key_here

Development & Contribution

Feel free to open issues or submit pull requests!


License

This project is licensed under the MIT License.


Acknowledgments

Built using Rich for beautiful console output and various AI translation models.

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

error_translator-0.1.0.tar.gz (2.1 kB view details)

Uploaded Source

Built Distribution

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

error_translator-0.1.0-py3-none-any.whl (2.1 kB view details)

Uploaded Python 3

File details

Details for the file error_translator-0.1.0.tar.gz.

File metadata

  • Download URL: error_translator-0.1.0.tar.gz
  • Upload date:
  • Size: 2.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for error_translator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5c67bdabf627501c8f093862f0c41382755d3c47c375c4005cd9f4831cf4c01d
MD5 1b6769d9b0f5b5babc8ee43f61d4fdaa
BLAKE2b-256 9e72b605c5ebcdacce2e990775a61b5121b4cb77438138d394c97057ccfcafe9

See more details on using hashes here.

File details

Details for the file error_translator-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for error_translator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 861fe936106ef3550b39e467ea56d860f9b881ef85fb8b1398266dde4b6f2621
MD5 7b27f0b5ce0809e00e876a380c6c9e28
BLAKE2b-256 d61f39735251c185b39655dedcb8b3b87b7ea52694689a2641c7b9f119a92975

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