ppq: Highlight cheap models

This commit is contained in:
Jiri Jakes 2026-03-14 15:58:06 -03:00
parent 09c338e16e
commit 18a7d1f126

View file

@ -129,6 +129,14 @@
(or completion 0) (or completion 0)
currency)))) currency))))
(defun ppq--model-has-cheap-output-p (model)
"Check if MODEL has output price per 1M tokens in range [0, 1)."
(let* ((pricing (ppq--aget model 'pricing))
(completion (when pricing (ppq--aget pricing 'output_per_1M_tokens))))
(and (numberp completion)
(>= completion 0)
(< completion 1))))
(defun ppq--fetch-models-callback (status) (defun ppq--fetch-models-callback (status)
"Callback for async model fetching. STATUS is the url-retrieve status." "Callback for async model fetching. STATUS is the url-retrieve status."
(unless (plist-get status :error) (unless (plist-get status :error)
@ -276,13 +284,14 @@
(setq tabulated-list-entries (setq tabulated-list-entries
(mapcar (mapcar
(lambda (model) (lambda (model)
(list (ppq--aget model 'id) (let ((cheap-p (ppq--model-has-cheap-output-p model)))
(vector (list (ppq--aget model 'id)
(propertize (or (ppq--aget model 'name) "N/A") 'font-lock-face nil) (vector
(propertize (or (ppq--aget model 'id) "N/A") 'font-lock-face nil) (propertize (or (ppq--aget model 'name) "N/A") 'font-lock-face (if cheap-p '(:foreground "green") nil))
(propertize (ppq--format-created-at (ppq--aget model 'created_at)) 'font-lock-face nil) (propertize (or (ppq--aget model 'id) "N/A") 'font-lock-face (if cheap-p '(:foreground "green") nil))
(propertize (ppq--format-context-length (ppq--aget model 'context_length)) 'font-lock-face nil) (propertize (ppq--format-created-at (ppq--aget model 'created_at)) 'font-lock-face (if cheap-p '(:foreground "green") nil))
(propertize (ppq--format-pricing model) 'font-lock-face nil)))) (propertize (ppq--format-context-length (ppq--aget model 'context_length)) 'font-lock-face (if cheap-p '(:foreground "green") nil))
(propertize (ppq--format-pricing model) 'font-lock-face (if cheap-p '(:foreground "green") nil))))))
ppq--models-data)) ppq--models-data))
(tabulated-list-init-header) (tabulated-list-init-header)
(tabulated-list-print)) (tabulated-list-print))