Skip to content

roma-guru/smart-exceptions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

smart-exceptions

Better Python Stacktraces with power of AI. Now your problems are solved at the same moment they're arised!

Installation

pip install git+https://github.com/roma-guru/smart-exceptions

Usage

In file:

import smart_exceptions as se
se.init("your-openai-token")
se.install_handler()
...[code causing exception]...

In [debug] console global exception handler is suppressed and have to call GPT explicitly:

>>> import smart_exceptions as se; se.init("your-openai-token")
>>> ...[code causing exception]...
>>> se.ask_gpt()

You can provide token explicitly or implicitly via $OPENAI_TOKEN. Also you can specify proxy explicitly or via $OPENAI_PROXY. Example

TODO

  • Autoinit from env (*_TOKEN) ???
  • TOken counting
  • Better pytest support

Pytest support

Place this in conftest.py:

import smart_exceptions as se
se.init()


def pytest_exception_interact(node, call, report):
    exc_info = (call.excinfo.type, call.excinfo.value, call.excinfo.traceback[0]._rawentry)
    se.gpt_backend.ask_gpt(exc_info)

About

Better Python Stacktraces with power of AI.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages