Skip to content

Commit

Permalink
Fix URL, fix function call
Browse files Browse the repository at this point in the history
  • Loading branch information
nicovank committed Dec 19, 2023
1 parent 947cdda commit 7dd8896
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/chatdbg/chatdbg_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")

0 comments on commit 7dd8896

Please sign in to comment.