From 18a7d1f1264463399ab3165a19a33b0e93057328 Mon Sep 17 00:00:00 2001 From: Jiri Jakes Date: Sat, 14 Mar 2026 15:58:06 -0300 Subject: [PATCH] ppq: Highlight cheap models --- ppq-status.el | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/ppq-status.el b/ppq-status.el index 554f7ec..afbaee5 100644 --- a/ppq-status.el +++ b/ppq-status.el @@ -129,6 +129,14 @@ (or completion 0) 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) "Callback for async model fetching. STATUS is the url-retrieve status." (unless (plist-get status :error) @@ -276,13 +284,14 @@ (setq tabulated-list-entries (mapcar (lambda (model) - (list (ppq--aget model 'id) - (vector - (propertize (or (ppq--aget model 'name) "N/A") 'font-lock-face nil) - (propertize (or (ppq--aget model 'id) "N/A") 'font-lock-face nil) - (propertize (ppq--format-created-at (ppq--aget model 'created_at)) 'font-lock-face nil) - (propertize (ppq--format-context-length (ppq--aget model 'context_length)) 'font-lock-face nil) - (propertize (ppq--format-pricing model) 'font-lock-face nil)))) + (let ((cheap-p (ppq--model-has-cheap-output-p model))) + (list (ppq--aget model 'id) + (vector + (propertize (or (ppq--aget model 'name) "N/A") 'font-lock-face (if cheap-p '(:foreground "green") nil)) + (propertize (or (ppq--aget model 'id) "N/A") 'font-lock-face (if cheap-p '(:foreground "green") nil)) + (propertize (ppq--format-created-at (ppq--aget model 'created_at)) 'font-lock-face (if cheap-p '(:foreground "green") 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)) (tabulated-list-init-header) (tabulated-list-print))