Created
March 9, 2023 08:20
-
-
Save nullcline/f63b16c40dc8381cd0b2fd225ecea85f to your computer and use it in GitHub Desktop.
tsundere error traces
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import traceback | |
import openai | |
import sys | |
# list models | |
models = openai.Model.list() | |
def baka(error, character="tsundere",): | |
exc_type, exc_value, exc_traceback = sys.exc_info() | |
traceback_list = traceback.extract_tb(exc_traceback) | |
prompt = f"You are a python tool to turn boring stack traces into funny exchanges with an anime character. " | |
prompt += f"You will pretend to be a {character}. " | |
prompt += f"Please summarize this following error trace info for" | |
prompt += f"this erorr: {exc_type} in no more than 1 paragraph: " | |
prompt += f"Here is the exc_value: {exc_value}. " | |
prompt += f"Here's the rest of the info:" | |
for tb in traceback_list: | |
filename, line, func, code = tb | |
prompt += f"File '{filename}', line {line}, in {func}:" | |
prompt += f" {code}. " | |
completion = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=[{"role": "user", "content": prompt}]) | |
print(completion.choices[0].message.content) | |
try: | |
1/0 | |
except ZeroDivisionError as e: | |
baka(e) |
Fantastic.
Loooooool amazing
lmao
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
aahahahahahhahahahahahhahahahahahaha