diff --git a/early-init.el b/early-init.el index 3992995..f553d4c 100644 --- a/early-init.el +++ b/early-init.el @@ -7,7 +7,8 @@ ;; ;; it is possible there are more so probably the most recent one is the one to use. -(setq elpaca-core-date "20241111") +(if emacs-build-time + (setq elpaca-core-date (format-time-string "%Y%m%d" emacs-build-time))) (defvar elpaca-installer-version 0.8) (defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory)) (defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory)) diff --git a/init.org b/init.org index 9d97879..a4fb1b4 100644 --- a/init.org +++ b/init.org @@ -41,58 +41,59 @@ one to use. #+BEGIN_SRC emacs-lisp :tangle "early-init.el" -;;; Bootstrap elpaca -(setq package-enable-at-startup nil) + ;;; Bootstrap elpaca + (setq package-enable-at-startup nil) -;; for guix emacs-next packages you can find the date with -;; ➜ stat /gnu/store/*emacs-next-[23]*.drv | rg Birth | cut -d' ' -f3 | tr -d '-' -;; 20240727 -;; -;; it is possible there are more so probably the most recent one is the one to use. + ;; for guix emacs-next packages you can find the date with + ;; ➜ stat /gnu/store/*emacs-next-[23]*.drv | rg Birth | cut -d' ' -f3 | tr -d '-' + ;; 20240727 + ;; + ;; it is possible there are more so probably the most recent one is the one to use. -(setq elpaca-core-date "20241111") -(defvar elpaca-installer-version 0.8) -(defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory)) -(defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory)) -(defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory)) -(defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git" - :ref nil :depth 1 - :files (:defaults "elpaca-test.el" (:exclude "extensions")) - :build (:not elpaca--activate-package))) -(let* ((repo (expand-file-name "elpaca/" elpaca-repos-directory)) - (build (expand-file-name "elpaca/" elpaca-builds-directory)) - (order (cdr elpaca-order)) - (default-directory repo)) - (add-to-list 'load-path (if (file-exists-p build) build repo)) - (unless (file-exists-p repo) - (make-directory repo t) - (when (< emacs-major-version 28) (require 'subr-x)) - (condition-case-unless-debug err - (if-let* ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*")) - ((zerop (apply #'call-process `("git" nil ,buffer t "clone" - ,@(when-let* ((depth (plist-get order :depth))) - (list (format "--depth=%d" depth) "--no-single-branch")) - ,(plist-get order :repo) ,repo)))) - ((zerop (call-process "git" nil buffer t "checkout" - (or (plist-get order :ref) "--")))) - (emacs (concat invocation-directory invocation-name)) - ((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch" - "--eval" "(byte-recompile-directory \".\" 0 'force)"))) - ((require 'elpaca)) - ((elpaca-generate-autoloads "elpaca" repo))) - (progn (message "%s" (buffer-string)) (kill-buffer buffer)) - (error "%s" (with-current-buffer buffer (buffer-string)))) - ((error) (warn "%s" err) (delete-directory repo 'recursive)))) - (unless (require 'elpaca-autoloads nil t) - (require 'elpaca) - (elpaca-generate-autoloads "elpaca" repo) - (load "./elpaca-autoloads"))) -(add-hook 'after-init-hook #'elpaca-process-queues) -(elpaca `(,@elpaca-order)) + (if emacs-build-time + (setq elpaca-core-date (format-time-string "%Y%m%d" emacs-build-time))) + (defvar elpaca-installer-version 0.8) + (defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory)) + (defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory)) + (defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory)) + (defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git" + :ref nil :depth 1 + :files (:defaults "elpaca-test.el" (:exclude "extensions")) + :build (:not elpaca--activate-package))) + (let* ((repo (expand-file-name "elpaca/" elpaca-repos-directory)) + (build (expand-file-name "elpaca/" elpaca-builds-directory)) + (order (cdr elpaca-order)) + (default-directory repo)) + (add-to-list 'load-path (if (file-exists-p build) build repo)) + (unless (file-exists-p repo) + (make-directory repo t) + (when (< emacs-major-version 28) (require 'subr-x)) + (condition-case-unless-debug err + (if-let* ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*")) + ((zerop (apply #'call-process `("git" nil ,buffer t "clone" + ,@(when-let* ((depth (plist-get order :depth))) + (list (format "--depth=%d" depth) "--no-single-branch")) + ,(plist-get order :repo) ,repo)))) + ((zerop (call-process "git" nil buffer t "checkout" + (or (plist-get order :ref) "--")))) + (emacs (concat invocation-directory invocation-name)) + ((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch" + "--eval" "(byte-recompile-directory \".\" 0 'force)"))) + ((require 'elpaca)) + ((elpaca-generate-autoloads "elpaca" repo))) + (progn (message "%s" (buffer-string)) (kill-buffer buffer)) + (error "%s" (with-current-buffer buffer (buffer-string)))) + ((error) (warn "%s" err) (delete-directory repo 'recursive)))) + (unless (require 'elpaca-autoloads nil t) + (require 'elpaca) + (elpaca-generate-autoloads "elpaca" repo) + (load "./elpaca-autoloads"))) + (add-hook 'after-init-hook #'elpaca-process-queues) + (elpaca `(,@elpaca-order)) -;; Enable :elpaca use-package keyword. -(elpaca elpaca-use-package - (elpaca-use-package-mode)) + ;; Enable :elpaca use-package keyword. + (elpaca elpaca-use-package + (elpaca-use-package-mode)) @@ -988,40 +989,74 @@ whether to put it under writing, comms or programming as it is equally #+BEGIN_SRC emacs-lisp (use-package llm :ensure t - :commands (llm-chat llm-ask-about llm-ask-line llm-ask-selection)) -#+END_SRC - -#+BEGIN_SRC emacs-lisp - (use-package llm-openai - :ensure nil - :requires llm - :commands (make-llm-openai)) -#+END_SRC - - -#+BEGIN_SRC emacs-lisp - (use-package ellama - :ensure t - :requires (llm llm-openai) - :commands (ellama-chat ellama-ask-about ellama-ask-line ellama-ask-selection) + :commands (llm-chat llm-ask-about llm-ask-line llm-ask-selection make-llm-openai make-llm-gemini) :custom - (ellama-language "English") - (ellama-provider - (make-llm-openai - :key (auth-source-pass-get 'secret "snamellit/openai-api-key") - :chat-model "gpt-4o" - )) - (ellama-sessions-directory (expand-file-name "~/Nextcloud/ellama-sessions")) - :bind-keymap - ("C-c e" . ellama-command-map)) + (llm-vertex-gcloud-region "europe-west3") + :config + (require 'llm-openai) + (require 'llm-vertex) + ) #+END_SRC #+RESULTS: -: [nil 26420 49222 463525 nil elpaca-process-queues nil nil 237000 nil] +: [nil 26492 6451 233211 nil elpaca-process-queues nil nil 232000 nil] + +#+RESULTS:g + +#+BEGIN_SRC emacs-lisp + (use-package ellama + :ensure t + :requires (llm) + :commands (ellama-chat ellama-ask-about ellama-ask-line ellama-ask-selection) + :custom + (ellama-language "English") + (ellama-sessions-directory (expand-file-name "~/Nextcloud/ellama-sessions")) + :bind-keymap + ("C-c e" . ellama-command-map) + :init + (setopt ellama-providers + '(("openai" . (make-llm-openai + :key (auth-source-pass-get 'secret "snamellit/openai-api-key") + :chat-model "gpt-4o")) + ("unifylearn" . (make-llm-vertex + :project "com-melexis-prod-unifylearn"))))) +#+END_SRC + +#+RESULTS: +: [nil 26492 1502 118737 nil elpaca-process-queues nil nil 57000 nil] It seems the *gpt-4o* model provides better responses. I should investigate local models more. +*** Use Gemini with ellama + + + +This is mostly for those who want to use Google Cloud specifically, most users should use Gemini instead, which is easier to set up. + +You can set up with make-llm-vertex, with the following parameters: + + +| paramter | description | +|------------------+-------------------------------------------------------------------------------------------------------------------------| +| | | +| :project | Your project number from Google Cloud that has Vertex API enabled. | +| :chat-model | A model name from the list of Vertex's model names. This is optional, and will default to a reasonable model. | +| :embedding-model | A model name from the list of Vertex's embedding model names. This is optional, and will default to a reasonable model. | + +In addition to the provider, which you may want multiple of (for example, to charge against different projects), there are customizable variables: + + - llm-vertex-gcloud-binary: The binary to use for generating the API key. + - llm-vertex-gcloud-region: The gcloud region to use. It's good to set this to a region near where you are for best latency. Defaults to "us-central1". + + If you haven't already, you must run the following command before using this: + + +#+BEGIN_SRC shell :tangle no +gcloud beta services identity create --service=aiplatform.googleapis.com --project=PROJECT_ID +#+END_SRC + + ** Dired Configuration Enables an alternative file navigation behavior in Dired, Emacs' directory editor: #+BEGIN_SRC emacs-lisp diff --git a/snippets/org-mode/elisp source block b/snippets/org-mode/elisp source block index 99a976d..b2a49e7 100644 --- a/snippets/org-mode/elisp source block +++ b/snippets/org-mode/elisp source block @@ -1,5 +1,5 @@ # -*- mode: snippet -*- -# name: source block +# name: source block emacs-lisp # key: