Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
nicovank committed Dec 19, 2023
1 parent 43ea806 commit bdb0165
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/chatdbg/chatdbg_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def explain(source_code: str, traceback: str, exception: str, really_run=True) -
return

input_tokens = llm_utils.count_tokens(model, user_prompt)

if not really_run:
print(user_prompt)
print(f"Total input tokens: {input_tokens}")
Expand All @@ -85,8 +85,12 @@ 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)
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
)
text += f"\n(Total cost: approximately ${cost:.2f} USD.)"
print(llm_utils.word_wrap_except_code_blocks(text))
except openai.error.AuthenticationError:
Expand Down
1 change: 1 addition & 0 deletions src/chatdbg/chatdbg_why.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from llm_utils import llm_utils


def why(self, arg):
user_prompt = "Explain what the root cause of this error is, given the following source code and traceback, and generate code that fixes the error."
user_prompt += "\n"
Expand Down

0 comments on commit bdb0165

Please sign in to comment.