From 7dd8896cf4d05603b4673a0aeeabca4dbda6e52b Mon Sep 17 00:00:00 2001 From: Nicolas van Kempen Date: Tue, 19 Dec 2023 08:37:48 -0500 Subject: [PATCH] Fix URL, fix function call --- src/chatdbg/chatdbg_utils.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/chatdbg/chatdbg_utils.py b/src/chatdbg/chatdbg_utils.py index 45b52ac..acdcf81 100644 --- a/src/chatdbg/chatdbg_utils.py +++ b/src/chatdbg/chatdbg_utils.py @@ -83,16 +83,10 @@ def explain(source_code: str, traceback: str, exception: str, really_run=True) - text = completion.choices[0].message.content input_tokens = completion.usage.prompt_tokens output_tokens = completion.usage.completion_tokens - context_window = ( - "8K" if model == "gpt-4" else "4K" - ) # FIXME: true as of Oct 3, 2023 - cost = llm_utils.calculate_cost( - input_tokens, output_tokens, model, context_window - ) + cost = llm_utils.calculate_cost(input_tokens, output_tokens, model) text += f"\n(Total cost: approximately ${cost:.2f} USD.)" print(llm_utils.word_wrap_except_code_blocks(text)) except openai.error.AuthenticationError: - print( - "You need a valid OpenAI key to use ChatDBG. You can get a key here: https://openai.com/api/" - ) + print("You need a valid OpenAI key to use ChatDBG.") + print("You can get a key here: https://platform.openai.com/api-keys") print("Set the environment variable OPENAI_API_KEY to your key value.")