added a mechanism to easily add definitions to the ellama context
This commit is contained in:
parent
0cbc93d1c2
commit
51c36a256d
|
|
@ -0,0 +1,42 @@
|
|||
;;; 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
|
||||
"Filetags: Used for note categorization and organization.
|
||||
Syntax: '# +filetags: :tag1:tag2:tag3:'
|
||||
- Each tag is enclosed in colons
|
||||
- Multiple tags can be specified
|
||||
- Placed at the beginning of a note file
|
||||
Example: '# +filetags: :work:project:urgent:'
|
||||
Purpose: Enable efficient filtering and searching of notes."))
|
||||
(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.
|
||||
|
|
@ -26,6 +26,7 @@
|
|||
(local-set-key (kbd "C-c C-k") 'ellama-capture-abort)
|
||||
(local-set-key (kbd "C-c f") 'ellama-context-add-file)
|
||||
(local-set-key (kbd "C-c i") 'ellama-context-add-info-node)
|
||||
(local-set-key (kbd "C-c d") 'ellama-capture-add-definition)
|
||||
(setq header-line-format
|
||||
(substitute-command-keys
|
||||
"C-c C-c: send, C-c C-k: abort, C-c f: add file, C-c i: add info node")))
|
||||
|
|
@ -51,6 +52,8 @@
|
|||
(quit-window t)
|
||||
(message "Ellama input aborted"))
|
||||
|
||||
(require 'module-ellama-capture-definitions)
|
||||
|
||||
(global-set-key (kbd "C-x A SPC") #'ellama-capture)
|
||||
|
||||
(provide 'module-ellama-capture)
|
||||
|
|
|
|||
|
|
@ -26,17 +26,19 @@
|
|||
(with-eval-after-load 'ellama
|
||||
(ellama-setup-keymap))
|
||||
|
||||
;; FIXME: ellama-context-add-file does not accept arguments. may
|
||||
;; explain why this doesn't work as expected.
|
||||
(defun ellama-context-add-marked-files ()
|
||||
"Add all marked files in Dired to Ellama context."
|
||||
(interactive)
|
||||
(let ((marked-files (dired-get-marked-files)))
|
||||
(let ((marked-files (dired-get-marked-files))
|
||||
(added-count 0))
|
||||
(if (null marked-files)
|
||||
(message "No files marked")
|
||||
(dolist (file marked-files)
|
||||
(ignore-errors (ellama-context-add-file file)))
|
||||
(message "Added %d file(s) to Ellama context" (length marked-files)))))
|
||||
(let ((default-directory (file-name-directory file)))
|
||||
(let ((element (ellama-context-element-file :name file)))
|
||||
(ellama-context-element-add element)
|
||||
(cl-incf added-count))))
|
||||
(message "Added %d file(s) to Ellama context" added-count))))
|
||||
|
||||
(with-eval-after-load 'dired
|
||||
(define-key dired-mode-map (kbd "C-c e") #'ellama-context-add-marked-files))
|
||||
|
|
|
|||
Loading…
Reference in New Issue