Skip to content

Instantly share code, notes, and snippets.

@nullcline
Created March 9, 2023 08:20
Show Gist options
  • Star 29 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nullcline/f63b16c40dc8381cd0b2fd225ecea85f to your computer and use it in GitHub Desktop.
Save nullcline/f63b16c40dc8381cd0b2fd225ecea85f to your computer and use it in GitHub Desktop.
tsundere error traces
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)
@yacineMTB
Copy link

aahahahahahhahahahahahhahahahahahaha

@drpedrazas
Copy link

Fantastic.

@mermelstein
Copy link

Loooooool amazing

@hursh-desai
Copy link

lmao

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment