syscfg/emacs/module/module-llm.el

50 lines
1.4 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))
(defun ellama-context-add-marked-files ()
"Add all marked files in Dired to Ellama context."
(interactive)
(let ((marked-files (dired-get-marked-files))
(added-count 0))
(if (null marked-files)
(message "No files marked")
(dolist (file 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))
(require 'module-ellama-capture)
(provide 'module-llm)
;;; module-llm.el ends here.