syscfg/emacs/module/module-ellama-capture-defin...

39 lines
1.8 KiB
EmacsLisp

;;; module-ellama-capture-definition.el --- Ellama capture definitions
;;;
;;; Commentary:
;;;
;;; This file provides functions to interactively add definitions to
;;; the Ellama context. This can be useful, for example, when dealing
;;; with custom data formats, such as denote notes, where the training
;;; data is unlikely to contain information about the format.
;;;
;;; Code:
(require 'ellama)
(defun ellama-capture-add-definition ()
"Interactively choose and add a definition to the Ellama context."
(interactive)
(let* ((funcs (apropos-internal "^ellama-capture-add-.*-definition$"))
(choices (mapcar (lambda (func)
(string-match "ellama-capture-add-\\(.*\\)-definition" (symbol-name func))
(match-string 1 (symbol-name func)))
funcs))
(choice (completing-read "Choose definition to add: " choices nil t)))
(if (fboundp (intern (format "ellama-capture-add-%s-definition" choice)))
(funcall (intern (format "ellama-capture-add-%s-definition" choice)))
(message "No function found for %s" choice))))
(defun ellama-capture-add-filetag-definition ()
"Add the filetag definition to the Ellama context."
(interactive)
(let ((filetag-definition
"Search for exact matches of the specified filetag(s) in the provided files only. The user will provide a quoted string \":tag:\" in the response, and you shall search for an exact match. Do not rely on
keyword recognition or generating new filetags. Use this syntax to identify filetags: #+filetags:
:tag1:tag2:tag3:"))
(ellama-context-add-text filetag-definition)
(message "Filetag definition added to Ellama context")))
(provide 'module-ellama-capture-definitions)
;;; module-ellama-capture-definitions.el ends here.