syscfg/emacs/module/module-llm.el

48 lines
1.3 KiB
EmacsLisp

;;; module-llm.el --- bullshit generators -*- lexical-binding: t; -*-
;;;
;;; Commentary:
;;; Provides interface to bullshit generators.
;;;
;;; Code:
(require 'module-pkg)
(pkg/require 'ellama)
(require 'llm-ollama)
(require 'dired)
(setq ellama-language "English")
(setq ellama-provider 'ollama)
(setq ellama-ollama-binary "/usr/local/bin/ollama")
(setopt ellama-provider
(make-llm-ollama
:chat-model "llama3:latest"
:embedding-model "nomic-embed-text"
:host "eris.fritz.box"
:default-chat-non-standard-params '(("num_ctx" . 8192))))
(setq ellama-keymap-prefix "C-x A") ;; ellama is the Assistant
(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)))
(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)))))
(with-eval-after-load 'dired
(define-key dired-mode-map (kbd "C-c e") #'ellama-context-add-marked-files))
(require 'module-ellama-capture)
(provide 'module-llm)
;;; module-llm.el ends here.