Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion gptel-org.el
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
(defvar org-link-angle-re)
(defvar org-link-bracket-re)
(declare-function mailcap-file-name-to-mime-type "mailcap")
(declare-function org-attach-expand "org-attach")
(declare-function gptel--model-capable-p "gptel")
(declare-function gptel--model-mime-capable-p "gptel")
(declare-function gptel--model-name "gptel")
Expand Down Expand Up @@ -365,8 +366,11 @@ for inclusion into the user prompt for the gptel request."
(when-let* ((link (org-element-context))
((gptel-org--link-standalone-p link))
(raw-link (org-element-property :raw-link link))
(path (org-element-property :path link))
(raw-path (org-element-property :path link))
(type (org-element-property :type link))
(path (if (string= type "attachment")
(org-attach-expand raw-path)
raw-path))
;; FIXME This is not a good place to check for url capability!
((member type `("attachment" "file"
,@(and (gptel--model-capable-p 'url)
Expand Down
9 changes: 6 additions & 3 deletions gptel-request.el
Original file line number Diff line number Diff line change
Expand Up @@ -2033,9 +2033,12 @@ Initiate the request when done."
(save-excursion (goto-char (point-min))
(gptel--parse-list-and-insert (cdr directive))))
(goto-char (point-max))
(setq full-prompt (gptel--parse-buffer ;prompt from buffer or explicitly supplied
gptel-backend (and gptel--num-messages-to-send
(* 2 gptel--num-messages-to-send))))
;; Parse buffer in original buffer context so org-attach-expand can access
;; Org properties (ID, ATTACH_DIR) not present in the temp copy buffer
(setq full-prompt (with-current-buffer (plist-get info :buffer)
(gptel--parse-buffer ;prompt from buffer or explicitly supplied
gptel-backend (and gptel--num-messages-to-send
(* 2 gptel--num-messages-to-send)))))
;; Inject media chunks into the first user prompt if required. Media
;; chunks are always included with the first user message,
;; irrespective of the preference in `gptel-use-context'. This is
Expand Down