Fix open-file-inactive, disable multiple tools
This commit is contained in:
parent
399039e980
commit
c0bbb50382
2 changed files with 9 additions and 126 deletions
16
README.org
16
README.org
|
@ -296,15 +296,13 @@ Opens a file into an inactive (background) buffer for processing.
|
|||
(defun gptel-org-tools--open-file-inactive (file)
|
||||
"Open FILE in a buffer."
|
||||
(with-current-buffer (get-buffer-create file)
|
||||
(insert-file-contents file)
|
||||
(concat
|
||||
(current-buffer))))
|
||||
(current-buffer)))
|
||||
|
||||
(add-to-list 'gptel-org-tools
|
||||
(gptel-make-tool
|
||||
:function #'gptel-org-tools--open-file-inactive
|
||||
:name "gptel-org-tools--open-file-inactive"
|
||||
:description "Open the file in a background buffer. This doesn't interfere with the user. After calling this tool, stop. Then continue fulfilling user's request."
|
||||
:description "Open the file in a background buffer. This does NOT return the contents of the file. After calling this tool, stop. Then continue fulfilling user's request."
|
||||
:args (list '(:name "file"
|
||||
:type string
|
||||
:description "Path to file.."))
|
||||
|
@ -740,7 +738,7 @@ And, the "grab everything that matches" tool.
|
|||
#+end_src
|
||||
|
||||
***** org-ql-select-regexp
|
||||
#+begin_src elisp
|
||||
#+begin_src elisp :tangle no
|
||||
(defun gptel-org-tools--org-ql-select-regexp (buf query)
|
||||
(let* ((buffer (get-buffer buf))
|
||||
(mode (buffer-local-value 'major-mode buffer)))
|
||||
|
@ -773,7 +771,7 @@ And, the "grab everything that matches" tool.
|
|||
|
||||
***** org-ql-select-all-tags-local
|
||||
This pulls all the headings (and their contents) when they match tags (without inheritance.)
|
||||
#+begin_src elisp
|
||||
#+begin_src elisp :tangle no
|
||||
(defun gptel-org-tools--org-ql-select-all-tags-local (query)
|
||||
"Return entries whose tags match QUERY in org-agenda-files.
|
||||
QUERY is the tag to search for."
|
||||
|
@ -798,7 +796,7 @@ This pulls all the headings (and their contents) when they match tags (without i
|
|||
|
||||
***** org-ql-select-all-tags
|
||||
This pulls all the headings (and their contents) when they match tags (with inheritance; if a parent entry has the tag, descendant entries do, too.)
|
||||
#+begin_src elisp
|
||||
#+begin_src elisp :tangle no
|
||||
(defun gptel-org-tools--org-ql-select-all-tags (query)
|
||||
"Return entries whose tags match QUERY,
|
||||
with inheritance, in org-agenda-files.
|
||||
|
@ -832,7 +830,7 @@ Note that I define my agenda in this way:
|
|||
|
||||
This means that /every org-mode file I have/ is part of this search. If you're using a different set-up, or want to only use the LLM on specific files, then you should modify this function appropriately.
|
||||
|
||||
#+begin_src elisp
|
||||
#+begin_src elisp :tangle no
|
||||
(defun gptel-org-tools--org-ql-select-all-rifle (query)
|
||||
"Return entries containing QUERY from org-agenda-files.
|
||||
QUERY is the keyword to search for."
|
||||
|
@ -857,7 +855,7 @@ This means that /every org-mode file I have/ is part of this search. If you're u
|
|||
|
||||
|
||||
***** org-ql-select-all-regexp
|
||||
#+begin_src elisp
|
||||
#+begin_src elisp :tangle no
|
||||
(defun gptel-org-tools--org-ql-select-all-regexp (query)
|
||||
"Return all entries matching regexp QUERY in org-agenda-files.
|
||||
QUERY is a regular expression."
|
||||
|
|
|
@ -108,15 +108,13 @@
|
|||
(defun gptel-org-tools--open-file-inactive (file)
|
||||
"Open FILE in a buffer."
|
||||
(with-current-buffer (get-buffer-create file)
|
||||
(insert-file-contents file)
|
||||
(concat
|
||||
(current-buffer))))
|
||||
(current-buffer)))
|
||||
|
||||
(add-to-list 'gptel-org-tools
|
||||
(gptel-make-tool
|
||||
:function #'gptel-org-tools--open-file-inactive
|
||||
:name "gptel-org-tools--open-file-inactive"
|
||||
:description "Open the file in a background buffer. This doesn't interfere with the user. After calling this tool, stop. Then continue fulfilling user's request."
|
||||
:description "Open the file in a background buffer. This does NOT return the contents of the file. After calling this tool, stop. Then continue fulfilling user's request."
|
||||
:args (list '(:name "file"
|
||||
:type string
|
||||
:description "Path to file.."))
|
||||
|
@ -421,118 +419,5 @@ After using this, stop. Evaluate the relevance of the results. Then continue."))
|
|||
:category "org-ql"
|
||||
:description "Returns entries (heading and body) matching QUERY from BUFFER. This may pull too many results, only use if other tools fail. After using this, stop. Evaluate results. If necessary, re-plan. Only then proceed."))
|
||||
|
||||
(defun gptel-org-tools--org-ql-select-regexp (buf query)
|
||||
(let* ((buffer (get-buffer buf))
|
||||
(mode (buffer-local-value 'major-mode buffer)))
|
||||
(if buffer
|
||||
(if (eq mode 'org-mode)
|
||||
(let ((result
|
||||
(org-ql-select
|
||||
buffer
|
||||
`(regexp ,query)
|
||||
:action #'gptel-org-tools--heading-body)))
|
||||
(gptel-org-tools--result-limit result))
|
||||
(message "Buffer '%s' isn't an org-mode buffer." buf))
|
||||
(message "Buffer '%s' does not exist." buf))))
|
||||
|
||||
|
||||
(add-to-list 'gptel-org-tools
|
||||
(gptel-make-tool
|
||||
:function #'gptel-org-tools--org-ql-select-regexp
|
||||
:name "gptel-org-tools--org-ql-select-regexp"
|
||||
:description "Run regexp on ALL files at once."
|
||||
:args (list '(:name "buffer"
|
||||
:type string
|
||||
:description "The name of the buffer. See the NAME column in `list-buffers`. Using filename fails.")
|
||||
'(:name "query"
|
||||
:type string
|
||||
:description "Regexp, Emacs Lisp format. Automatically wrapped in a word boundary by the tool."))
|
||||
:category "org-ql"
|
||||
:description "Returns entries matching regexp QUERY from BUFFER. After using this, stop. Evaluate results for relevance, and proceed with completing user's request. The regexp *must* be in Emacs rx format!" ))
|
||||
|
||||
(defun gptel-org-tools--org-ql-select-all-tags-local (query)
|
||||
"Return entries whose tags match QUERY in org-agenda-files.
|
||||
QUERY is the tag to search for."
|
||||
(let ((result
|
||||
(org-ql-select
|
||||
(org-agenda-files)
|
||||
`(tags-local ,query)
|
||||
:action #'gptel-org-tools--heading-body)))
|
||||
(gptel-org-tools--result-limit result)))
|
||||
|
||||
|
||||
(add-to-list 'gptel-org-tools
|
||||
(gptel-make-tool
|
||||
:function #'gptel-org-tools--org-ql-select-all-tags-local
|
||||
:name "gptel-org-tools--org-ql-select-all-tags-local"
|
||||
:args (list '(:name "query"
|
||||
:type string
|
||||
:description "A single word to scan for."))
|
||||
:category "org-ql"
|
||||
:description "Returns entries whose tags match QUERY from all files, without tag inheritance. After using this, stop. Evaluate results. Then proceed with completing user's request."))
|
||||
|
||||
(defun gptel-org-tools--org-ql-select-all-tags (query)
|
||||
"Return entries whose tags match QUERY,
|
||||
with inheritance, in org-agenda-files.
|
||||
QUERY is the tag to search for."
|
||||
(let ((result
|
||||
(org-ql-select
|
||||
(org-agenda-files)
|
||||
`(tags ,query)
|
||||
:action #'gptel-org-tools--heading-body)))
|
||||
(gptel-org-tools--result-limit result)))
|
||||
|
||||
(add-to-list 'gptel-org-tools
|
||||
(gptel-make-tool
|
||||
:function #'gptel-org-tools--org-ql-select-all-tags
|
||||
:name "gptel-org-tools--org-ql-select-all-tags"
|
||||
:args (list '(:name "query"
|
||||
:type string
|
||||
:description "A simple (single) string to scan for."))
|
||||
:category "org-ql"
|
||||
:description "Returns entries whose tags match QUERY from BUFFER, with tag inheritance. After using this, stop. Evaluate results for relevance, and proceed with completing user's request."))
|
||||
|
||||
(defun gptel-org-tools--org-ql-select-all-rifle (query)
|
||||
"Return entries containing QUERY from org-agenda-files.
|
||||
QUERY is the keyword to search for."
|
||||
(let ((result
|
||||
(org-ql-select
|
||||
(org-agenda-files)
|
||||
`(rifle ,query)
|
||||
:action #'gptel-org-tools--heading-body)))
|
||||
(gptel-org-tools--result-limit result)))
|
||||
|
||||
(add-to-list 'gptel-org-tools
|
||||
(gptel-make-tool
|
||||
:function #'gptel-org-tools--org-ql-select-all-rifle
|
||||
:name "gptel-org-tools--org-ql-select-all-rifle"
|
||||
:description "Run simple (single) string against ALL org-mode files (notes)."
|
||||
:args (list '(:name "query"
|
||||
:type string
|
||||
:description "The string to match entry headings and content against."))
|
||||
:category "org-ql"
|
||||
:description "Returns entries matching QUERY from all files. After using this, stop. Evaluate results for relevance, and proceed with completing user's request." ))
|
||||
|
||||
(defun gptel-org-tools--org-ql-select-all-regexp (query)
|
||||
"Return all entries matching regexp QUERY in org-agenda-files.
|
||||
QUERY is a regular expression."
|
||||
(let ((result
|
||||
(org-ql-select
|
||||
(org-agenda-files)
|
||||
`(regexp ,query)
|
||||
:action #'gptel-org-tools--heading-body)))
|
||||
(gptel-org-tools--result-limit result)))
|
||||
|
||||
(add-to-list 'gptel-org-tools
|
||||
(gptel-make-tool
|
||||
:function #'gptel-org-tools--org-ql-select-all-regexp
|
||||
:name "gptel-org-tools--org-ql-select-all-regexp"
|
||||
:description "Run regexp on ALL files at once."
|
||||
:args (list '(:name "query"
|
||||
:type string
|
||||
:description "Regexp, Emacs Lisp format. Automatically wrapped in a word boundary by the tool."))
|
||||
:category "org-ql"
|
||||
:description "Returns entries matching regexp QUERY from all files. After using this, stop. Evaluate results for relevance, and proceed with completing user's request. The regexp *must* be in Emacs rx format!" ))
|
||||
|
||||
(provide 'gptel-org-tools)
|
||||
;;; gptel-org-tools.el ends here
|
||||
|
|
Loading…
Add table
Reference in a new issue