Files
memex/projects/dotemacs/docs/emacs-ai.org

3.6 KiB

AI Configuration

AI Settings

Ellama

  ;; YOU DON'T NEED NONE OF THIS CODE FOR SIMPLE INSTALL
  ;; IT IS AN EXAMPLE OF CUSTOMIZATION.
  (use-package ellama
    :init
    (require 'llm-openai)
    ;; setup key bindings
    (setq ellama-keymap-prefix "C-c e")
    )
  (setopt ellama-providers
  	'(
  	  ;; Ollama Provider (added here with a name)
  	  ("ollama" . (make-llm-ollama
                               ;; Consider a dedicated embedding model if gemma isn't ideal for it.
                               :chat-model "gemma3:latest"
                               :embedding-model "gemma3:latest" ; Or e.g., "nomic-embed-text"
                               :default-chat-non-standard-params '(("num_ctx" . 8192))))

  	  ("openai" . (make-llm-openai
                         :key (auth-source-pass-get "api-key" "www/openai.com/amr@gharbeia.net")
                         :chat-model "gpt-4o"
  		       :embedding-model "text-embedding-3-large"))

            ("groq" . (make-llm-openai-compatible
                       :url "https://api.groq.com/openai/v1"
                       :key (auth-source-pass-get "api-key" "www/console.groq.com/groq@amr.gharbeia.net")
                       ;; Check Groq console for available models, these might change
                       :chat-model "llama3-70b-8192" ; Example, verify on Groq
                       :embedding-model "llama3-70b-8192")) ; Groq might not offer dedicated embedding models via this API
            ))

  ;; --- Set Active Providers ---
  ;; Choose your default provider from the list above by its name
  (setopt ellama-provider "ollama") ; Or "ollama", "openai", "groq"

  ;; You can specify different providers for different tasks if needed
  (setopt ellama-translation-provider "ollama")
  (setopt ellama-naming-provider "ollama")
  (setopt ellama-naming-scheme 'ellama-generate-name-by-llm)

  (setq llm-debug t)
  (use-package ellama
  :ensure t
  :bind ("C-c e" . ellama)
  ;; send last message in chat buffer with C-c C-c
  :hook (org-ctrl-c-ctrl-c-final . ellama-chat-send-last-message)
  :init (setopt ellama-auto-scroll t)
  :config
  ;; show ellama context in header line in all buffers
  (ellama-context-header-line-global-mode +1)
  ;; show ellama session id in header line in all buffers
  (ellama-session-header-line-global-mode +1))

GPTel

  (use-package gptel)
  (setq gptel-api-key (auth-source-pass-get "api-key" "www/console.groq.com/groq@amr.gharbeia.net"))
  (gptel-make-openai "Groq"               ;Any name you want
  :host "api.groq.com"
  :endpoint "/openai/v1/chat/completions"
  :stream t
  :key (auth-source-pass-get "api-key" "www/console.groq.com/groq@amr.gharbeia.net")                   ;can be a function that returns the key
  :models '(llama-3.1-70b-versatile
            llama-3.1-8b-instant
            llama3-70b-8192
            llama3-8b-8192
            mixtral-8x7b-32768
            gemma-7b-it))

Elisa

  (use-package elisa
    :init
    (setopt elisa-limit 5)
    (require 'llm-ollama)
    (setopt elisa-embeddings-provider (make-llm-ollama :embedding-model "nomic-embed-text"))
    (setopt elisa-chat-provider (make-llm-ollama
                                 :chat-model "sskostyaev/openchat:8k-rag"
                                 :embedding-model "nomic-embed-text"))
    )