Function: gptel--update-token-usage
gptel--update-token-usage is a natively compiled function defined in
gptel.el.
Signature
(gptel--update-token-usage TOKENS &optional TOKENS-FULL)
Documentation
Update token usage information for buffer from TOKENS.
TOKENS is the token usage for the current turn. TOKENS-FULL is the cumulative token usage for the request (so far).
Source Code
;; Defined in /nix/store/q3r7g81pvghw7a523kjk2k2zih3pfk8z-emacs-packages-deps/share/emacs/site-lisp/elpa/gptel-20261002.545/gptel.el
(defun gptel--update-token-usage (tokens &optional tokens-full)
"Update token usage information for buffer from TOKENS.
TOKENS is the token usage for the current turn.
TOKENS-FULL is the cumulative token usage for the request (so far)."
(when tokens
(let ((tokens-full (or tokens-full tokens)))
(if (not gptel--token-usage)
(setq gptel--token-usage (list tokens-full (copy-sequence tokens-full)))
(setcar gptel--token-usage tokens-full)
(cl-callf gptel--sum-plists (nth 1 gptel--token-usage) tokens))
(unless gptel--token-usage-strings ;show buffer usage by default
(setq gptel--token-usage-strings (list 1)))
(setcdr gptel--token-usage-strings
(mapcar #'gptel--format-token-usage gptel--token-usage)))))