mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-28 00:05:01 +00:00
Merge pull request #244 from joshuavial/fix-openrouter-token-usage
only show token costs if usage exists
This commit is contained in:
commit
7ba70632e8
1 changed files with 13 additions and 9 deletions
|
@ -606,6 +606,8 @@ class Coder:
|
|||
self.io.tool_error(show_content_err)
|
||||
raise Exception("No data found in openai response!")
|
||||
|
||||
tokens = None
|
||||
if hasattr(completion, 'usage'):
|
||||
prompt_tokens = completion.usage.prompt_tokens
|
||||
completion_tokens = completion.usage.completion_tokens
|
||||
|
||||
|
@ -625,6 +627,8 @@ class Coder:
|
|||
show_resp = Text(show_resp or "<no response>")
|
||||
|
||||
self.io.console.print(show_resp)
|
||||
|
||||
if tokens is not None:
|
||||
self.io.tool_output(tokens)
|
||||
|
||||
def show_send_output_stream(self, completion):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue