From a5f5801b96abd838f61930e141029e01a7aff9f0 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Thu, 15 Jun 2023 17:38:25 +0100 Subject: [PATCH] Better error message for invalid API key --- llm/cli.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/llm/cli.py b/llm/cli.py index 30d2692..1043514 100644 --- a/llm/cli.py +++ b/llm/cli.py @@ -112,6 +112,8 @@ def openai_(prompt, system, gpt4, model, stream, no_log, code, _continue, chat_i if code: content = unwrap_markdown(content) print(content) + except openai.error.AuthenticationError as ex: + raise click.ClickException("{}: {}".format(ex.error.type, ex.error.code)) except openai.error.OpenAIError as ex: raise click.ClickException(str(ex))