Refactor: Improve how to get total token count for AnthropicCV (#10658)

### What problem does this PR solve?

 Improve how to get total token count for AnthropicCV

### Type of change

- [x] Refactoring
This commit is contained in:
Stephen Hu
2025-10-29 09:41:15 +08:00
committed by GitHub
parent e86bd723d1
commit d86d7061ea
2 changed files with 9 additions and 4 deletions

View File

@ -63,6 +63,12 @@ def total_token_count_from_response(resp):
return resp["usage"]["total_tokens"]
except Exception:
pass
if 'usage' in resp and 'input_tokens' in resp['usage'] and 'output_tokens' in resp['usage']:
try:
return resp["usage"]["input_tokens"] + resp["usage"]["output_tokens"]
except Exception:
pass
return 0