andreasblixt
andreasblixt t1_izntugx wrote
Reply to [P] I made a command-line tool that explains your errors using ChatGPT (link in comments) by jsonathan
Nice! I think its answer would be much more contextual if you made the prompt something like this:
Please explain concisely why this error in my Python code happened:
Traceback ...
...
Based on these lines of code surrounding the trace:
broken.py
1 ...
2 ...
...
11 ...
I would aggregate those lines in a map of file_name: str
-> line_numbers: set
where you basically do lines["broken.py"].update(range(error_lineno - 5, error_lineno + 5))
(with boundary checking etc ofc) so that you can then aggregate all the relevant lines with context, without overlap.
andreasblixt t1_iu3hw2a wrote
Reply to [R] "Re3: Generating Longer Stories With Recursive Reprompting and Revision" - Generating stories of 2000+ words (or even much longer) by 0xWTC
Now please run this on all of /r/WritingPrompts
andreasblixt t1_izo7j6o wrote
Reply to comment by andreasblixt in [P] I made a command-line tool that explains your errors using ChatGPT (link in comments) by jsonathan
For the fun of it, I asked ChatGPT to generate the solution for creating the output above, and it didn't get it 100% but it's a pretty good start! One of my favorite things is how it implicitly got that it should do
sorted(line_numbers)
becauseset
does not have a defined iteration order, or how it should make the line numbers right-aligned.Here is some sample code that demonstrates how you can write a Python program that turns a raised exception into the desired output. This code is not complete, but it should give you a good starting point:
To use this code, you would call the
turn_exception_into_output
function whenever you want to handle an exception and print the desired output. For example:You could also use this code as part of a custom exception handler. For example:
With this code, whenever an unhandled exception is raised, the
custom_exception_handler
function will be called, which will turn the exception into the desired output.