Skip to content

Commit

Permalink
Fixed to include cost message.
Browse files Browse the repository at this point in the history
  • Loading branch information
emeryberger committed Oct 4, 2023
1 parent c021f70 commit 4e087c9
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/chatdbg/chatdbg_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,8 @@ def explain(source_code: str, traceback: str, exception: str, really_run=True) -
output_tokens = completion.usage.completion_tokens
context_window = "8K" if model == "gpt-4" else "4K" # FIXME: true as of Oct 3, 2023
cost = calculate_cost(input_tokens, output_tokens, model, context_window)
text += f"\n(Total cost: approximately ${cost:.2f} USD.)"
print(word_wrap_except_code_blocks(text))
print()
text += f"(Total cost: approximately ${cost:.2f} USD.)"
except openai.error.AuthenticationError:
print(
"You need a valid OpenAI key to use ChatDBG. You can get a key here: https://openai.com/api/"
Expand Down

0 comments on commit 4e087c9

Please sign in to comment.