Copy whole object
This commit is contained in:
parent
a88e8fe7d6
commit
1900bf0f72
2 changed files with 26 additions and 12 deletions
|
|
@ -285,16 +285,23 @@
|
||||||
(let ((map (make-sparse-keymap)))
|
(let ((map (make-sparse-keymap)))
|
||||||
(set-keymap-parent map tabulated-list-mode-map)
|
(set-keymap-parent map tabulated-list-mode-map)
|
||||||
(define-key map "q" #'nano-gpt-quit)
|
(define-key map "q" #'nano-gpt-quit)
|
||||||
(define-key map "w" #'nano-gpt-models-copy-id)
|
(define-key map "w" #'nano-gpt-models-copy-nix-entry)
|
||||||
map))
|
map))
|
||||||
|
|
||||||
(defun nano-gpt-models-copy-id ()
|
(defun nano-gpt-models-copy-nix-entry ()
|
||||||
"Copy the ID of the current model to clipboard."
|
"Copy the current model as a Nix attribute set to clipboard."
|
||||||
(interactive)
|
(interactive)
|
||||||
(when tabulated-list-entries
|
(when tabulated-list-entries
|
||||||
(let* ((entry (tabulated-list-get-entry))
|
(let* ((id (tabulated-list-get-id))
|
||||||
(id (aref entry 1)))
|
(model (seq-find (lambda (m) (equal (nano-gpt--aget m 'id) id))
|
||||||
(kill-new id)
|
nano-gpt--models-data))
|
||||||
|
(name (nano-gpt--aget model 'name))
|
||||||
|
(pricing (nano-gpt--aget model 'pricing))
|
||||||
|
(input-price (or (nano-gpt--aget pricing 'prompt) 0))
|
||||||
|
(output-price (or (nano-gpt--aget pricing 'completion) 0))
|
||||||
|
(nix-str (format " \"%s\" = {\n name = \"%s\";\n cost = [%s %s];\n };"
|
||||||
|
id name (or input-price 0) (or output-price 0))))
|
||||||
|
(kill-new nix-str)
|
||||||
(message "Copied: %s" id))))
|
(message "Copied: %s" id))))
|
||||||
|
|
||||||
(define-derived-mode nano-gpt-models-mode tabulated-list-mode "Models"
|
(define-derived-mode nano-gpt-models-mode tabulated-list-mode "Models"
|
||||||
|
|
|
||||||
|
|
@ -373,16 +373,23 @@ PROJECT-NAME is the display name for the project."
|
||||||
(let ((map (make-sparse-keymap)))
|
(let ((map (make-sparse-keymap)))
|
||||||
(set-keymap-parent map tabulated-list-mode-map)
|
(set-keymap-parent map tabulated-list-mode-map)
|
||||||
(define-key map "q" #'ppq-quit)
|
(define-key map "q" #'ppq-quit)
|
||||||
(define-key map "w" #'ppq-models-copy-id)
|
(define-key map "w" #'ppq-models-copy-nix-entry)
|
||||||
map))
|
map))
|
||||||
|
|
||||||
(defun ppq-models-copy-id ()
|
(defun ppq-models-copy-nix-entry ()
|
||||||
"Copy the ID of the current model to clipboard."
|
"Copy the current model as a Nix attribute set to clipboard."
|
||||||
(interactive)
|
(interactive)
|
||||||
(when tabulated-list-entries
|
(when tabulated-list-entries
|
||||||
(let* ((entry (tabulated-list-get-entry))
|
(let* ((id (tabulated-list-get-id))
|
||||||
(id (aref entry 1)))
|
(model (seq-find (lambda (m) (equal (ppq--aget m 'id) id))
|
||||||
(kill-new id)
|
ppq--models-data))
|
||||||
|
(name (ppq--aget model 'name))
|
||||||
|
(pricing (ppq--aget model 'pricing))
|
||||||
|
(input-price (or (ppq--aget pricing 'input_per_1M_tokens) 0))
|
||||||
|
(output-price (or (ppq--aget pricing 'output_per_1M_tokens) 0))
|
||||||
|
(nix-str (format " \"%s\" = {\n name = \"%s\";\n cost = [%s %s];\n };"
|
||||||
|
id name (or input-price 0) (or output-price 0))))
|
||||||
|
(kill-new nix-str)
|
||||||
(message "Copied: %s" id))))
|
(message "Copied: %s" id))))
|
||||||
|
|
||||||
(defun ppq--format-created-at (epoch-ms)
|
(defun ppq--format-created-at (epoch-ms)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue