Skip to content

Commit a6319fd

Browse files
committed
prefill input when cursor is on a filename or link
rksm#122
1 parent f289562 commit a6319fd

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

org-ai-openai-image-query.el

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
;;; Code:
44

5-
;; TODO use file path or url at point as default
65
(require 'org-ai-openai)
76

87
(defcustom org-ai-image-query-model "gpt-4o-mini"
@@ -79,16 +78,10 @@ Calls CALLBACK with the response."
7978
;;;###autoload
8079
(defun org-ai-query-image ()
8180
"Query OpenAI API with a BASE64 encoded image path or URL and a QUESTION."
82-
(interactive)
83-
(let ((image-path-or-url (org-ai--get-image-path-or-url))
84-
(question (org-ai--get-question)))
85-
(if (string-match-p "^https?://" image-path-or-url)
86-
(org-ai--send-url-image-query image-path-or-url question #'org-ai--handle-openai-response)
87-
(let ((base64-image (with-temp-buffer
88-
(insert-file-contents-literally image-path-or-url)
89-
(base64-encode-region (point-min) (point-max))
90-
(buffer-string))))
91-
(org-ai--send-base64-image-query base64-image question #'org-ai--handle-openai-response)))))
81+
(interactive (list
82+
(read-file-name "Image file path: " nil nil nil (or (thing-at-point 'existing-filename)
83+
(thing-at-point 'url)))
84+
(read-string "Question: " nil 'minibuffer-history))))
9285

9386
(provide 'org-ai-openai-image-query)
9487

0 commit comments

Comments
 (0)