python 返ってきたエラーをChatGPTに解析してもらって表示

ちょっと時間かかるけど
けっこう便利よ。

import openai

openai.api_key = "sk-hogehoge"

def ask_question(question, model, context):

    chat = []
    chat.append({"role": "system", "content": context})
    chat.append({"role": "user", "content": question})
    response = openai.ChatCompletion.create(
        model="gpt-3.5-turbo",messages=chat
    )
    msg = response["choices"][0]["message"]["content"].lstrip()
    return msg


try:
	
	hogehoge

except Exception as e:
    print(f"Error : {e}")
    answer = ask_question(f"{e}","davinci","Please explain the meaning of the error in Japanese.")
    print(f"{answer}")