Skip to content

Commit

Permalink
reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
AAlexDing authored Nov 16, 2024
1 parent 4c16368 commit 771b927
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions api/core/model_runtime/model_providers/anthropic/llm/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,13 @@ def _handle_chat_generate_response(
assistant_prompt_message.tool_calls.append(tool_call)

# calculate num tokens
prompt_tokens = (response.usage and response.usage.input_tokens) or \
self.get_num_tokens(model, credentials, prompt_messages)

completion_tokens = (response.usage and response.usage.output_tokens) or \
self.get_num_tokens(model, credentials, [assistant_prompt_message])
prompt_tokens = (response.usage and response.usage.input_tokens) or self.get_num_tokens(
model, credentials, prompt_messages
)

completion_tokens = (response.usage and response.usage.output_tokens) or self.get_num_tokens(
model, credentials, [assistant_prompt_message]
)

# transform usage
usage = self._calc_response_usage(model, credentials, prompt_tokens, completion_tokens)
Expand Down

0 comments on commit 771b927

Please sign in to comment.