Ellama is a tool for interacting with large language models from Emacs. It allows you to ask questions and receive responses from the LLMs. Ellama can perform various tasks such as translation, code review, summarization, enhancing grammar/spelling or wording and more through the Emacs interface. Ellama natively supports streaming output, making it effortless to use with your preferred text editor.
The name “ellama” is derived from “Emacs Large LAnguage Model Assistant”. Previous sentence was written by Ellama itself.
Just M-x
package-install
Enter ellama
Enter. By default it uses
ollama provider and
zephyr model. If you ok with it,
you need to install ollama
and pull zephyr like this:
ollama pull zephyr
You can use ellama
with other model or other llm provider.
In that case you should customize ellama configuration like this:
(use-package ellama
:bind ("C-c e" . ellama-transient-main-menu)
:init
;; setup key bindings
;; (setopt ellama-keymap-prefix "C-c e")
;; language you want ellama to translate to
(setopt ellama-language "German")
;; could be llm-openai for example
(require 'llm-ollama)
(setopt ellama-provider
(make-llm-ollama
;; this model should be pulled to use it
;; value should be the same as you print in terminal during pull
:chat-model "llama3:8b-instruct-q8_0"
:embedding-model "nomic-embed-text"
:default-chat-non-standard-params '(("num_ctx" . 8192))))
(setopt ellama-summarization-provider
(make-llm-ollama
:chat-model "qwen2.5:3b"
:embedding-model "nomic-embed-text"
:default-chat-non-standard-params '(("num_ctx" . 32768))))
(setopt ellama-coding-provider
(make-llm-ollama
:chat-model "qwen2.5-coder:3b"
:embedding-model "nomic-embed-text"
:default-chat-non-standard-params '(("num_ctx" . 32768))))
;; Predefined llm providers for interactive switching.
;; You shouldn't add ollama providers here - it can be selected interactively
;; without it. It is just example.
(setopt ellama-providers
'(("zephyr" . (make-llm-ollama
:chat-model "zephyr:7b-beta-q6_K"
:embedding-model "zephyr:7b-beta-q6_K"))
("mistral" . (make-llm-ollama
:chat-model "mistral:7b-instruct-v0.2-q6_K"
:embedding-model "mistral:7b-instruct-v0.2-q6_K"))
("mixtral" . (make-llm-ollama
:chat-model "mixtral:8x7b-instruct-v0.1-q3_K_M-4k"
:embedding-model "mixtral:8x7b-instruct-v0.1-q3_K_M-4k"))))
;; Naming new sessions with llm
(setopt ellama-naming-provider
(make-llm-ollama
:chat-model "llama3:8b-instruct-q8_0"
:embedding-model "nomic-embed-text"
:default-chat-non-standard-params '(("stop" . ("\n")))))
(setopt ellama-naming-scheme 'ellama-generate-name-by-llm)
;; Translation llm provider
(setopt ellama-translation-provider
(make-llm-ollama
:chat-model "qwen2.5:3b"
:embedding-model "nomic-embed-text"
:default-chat-non-standard-params
'(("num_ctx" . 32768))))
;; customize display buffer behaviour
;; see ~(info "(elisp) Buffer Display Action Functions")~
(setopt ellama-chat-display-action-function #'display-buffer-full-frame)
(setopt ellama-instant-display-action-function #'display-buffer-at-bottom)
:config
;; send last message in chat buffer with C-c C-c
(add-hook 'org-ctrl-c-ctrl-c-hook #'ellama-chat-send-last-message))
Ask Ellama about something by entering a prompt in an interactive
buffer and continue conversation. If called with universal argument
(C-u
) will start new session with llm model interactive selection.
Send last user message extracted from current ellama chat buffer.
Ask Ellama about a selected region or the current buffer.
Send selected region or current buffer to ellama chat.
Send current line to ellama chat.
Complete text in current buffer with ellama.
Ask Ellama to translate a selected region or word at the point.
Translate current buffer.
Find the definition of the current word using Ellama.
Summarize a selected region or the current buffer using Ellama.
Summarize text from the kill ring.
Review code in a selected region or the current buffer using Ellama.
Change text in a selected region or the current buffer according to a provided change.
Create a markdown list from the active region or the current buffer using Ellama.
Create a markdown table from the active region or the current buffer using Ellama.
Summarize a webpage fetched from a URL using Ellama.
Select ellama provider.
Complete selected code or code in the current buffer according to a provided change using Ellama.
Add new code according to a description, generating it with a provided context from the selected region or the current buffer using Ellama.
Change selected code or code in the current buffer according to a provided change using Ellama.
Change selected code or code in the current buffer according to a provided change using Ellama.
Generate commit message based on diff.
Enhance the wording in the currently selected region or buffer using Ellama.
Enhance the grammar and spelling in the currently selected region or buffer using Ellama.
Make the text of the currently selected region or buffer concise and simple using Ellama.
Render the currently selected text or the text in the current buffer as a specified format using Ellama.
Load ellama session from file.
Remove ellama session.
Change current active session.
Rename current ellama session.
Add file to context.
Add buffer to context.
Add selected region to context.
Add info node to context.
Chat translation enable.
Chat translation disable.
Solve reasoning problem with Absctraction of Thought technique. It uses a chain of multiple messages to LLM and help it to provide much better answers on reasoning problems. Even small LLMs like phi3-mini provides much better results on reasoning tasks using AoT.
Solve domain specific problem with simple chain. It makes LLMs act like a professional and adds a planning step.
Here is a table of keybindings and their associated functions in
Ellama, using the ellama-keymap-prefix
prefix (not set by default):
Keymap | Function | Description |
---|---|---|
“c c” | ellama-code-complete | Code complete |
“c a” | ellama-code-add | Code add |
“c e” | ellama-code-edit | Code edit |
“c i” | ellama-code-improve | Code improve |
“c r” | ellama-code-review | Code review |
“c m” | ellama-generate-commit-message | Generate commit message |
”s s” | ellama-summarize | Summarize |
”s w” | ellama-summarize-webpage | Summarize webpage |
”s c” | ellama-summarize-killring | Summarize killring |
”s l” | ellama-load-session | Session Load |
”s r” | ellama-session-rename | Session rename |
”s d” | ellama-session-remove | Session delete |
”s a” | ellama-session-switch | Session activate |
“i w” | ellama-improve-wording | Improve wording |
“i g” | ellama-improve-grammar | Improve grammar and spelling |
“i c” | ellama-improve-conciseness | Improve conciseness |
“m l” | ellama-make-list | Make list |
“m t” | ellama-make-table | Make table |
“m f” | ellama-make-format | Make format |
“a a” | ellama-ask-about | Ask about |
“a i” | ellama-chat | Chat (ask interactively) |
“a l” | ellama-ask-line | Ask current line |
“a s” | ellama-ask-selection | Ask selection |
“t t” | ellama-translate | Text translate |
“t b” | ellama-translate-buffer | Translate buffer |
“t e” | ellama-chat-translation-enable | Translation enable |
“t d” | ellama-chat-translation-disable | Translation disable |
“t c” | ellama-complete | Text complete |
“d w” | ellama-define-word | Define word |
“x b” | ellama-context-add-buffer | Context add buffer |
“x f” | ellama-context-add-file | Context add file |
“x s” | ellama-context-add-selection | Context add selection |
“x i” | ellama-context-add-info-node | Context add info node |
“p s” | ellama-provider-select | Provider select |
The following variables can be customized for the Ellama client:
ellama-enable-keymap
: Enable the Ellama keymap.ellama-keymap-prefix
: The keymap prefix for Ellama.ellama-user-nick
: The user nick in logs.ellama-assistant-nick
: The assistant nick in logs.ellama-language
: The language for Ollama translation. Default
language is english.
ellama-provider
: llm provider for ellama. Default provider is
ollama
with zephyr model.
There are many supported providers: ollama
, open ai
, vertex
,
GPT4All
. For more information see llm documentation.
ellama-providers
: association list of model llm providers with name as key.ellama-spinner-type
: Spinner type for ellama. Default type is
progress-bar
.
ellama-ollama-binary
: Path to ollama binary.ellama-auto-scroll
: If enabled ellama buffer will scroll automatically during generation. Disabled by default.ellama-fill-paragraphs
: Option to customize ellama paragraphs filling behaviour.ellama-name-prompt-words-count
: Count of words in prompt to generate name.- Prompt templates for every command.
ellama-chat-done-callback
: Callback that will be called on ellama
chat response generation done. It should be a function with single argument generated text string.
ellama-nick-prefix-depth
: User and assistant nick prefix depth. Default value is 2.ellama-sessions-directory
: Directory for saved ellama sessions.ellama-major-mode
: Major mode for ellama commands. Org mode by default.ellama-long-lines-length
: Long lines length for fill paragraph call. Too low value can break generated code by splitting long comment lines. Default value 100.ellama-session-auto-save
: Automatically save ellama sessions if set. Enabled by default.ellama-naming-scheme
: How to name new sessions.ellama-naming-provider
: LLM provider for generating session names by LLM. If not setellama-provider
will be used.ellama-chat-translation-enabled
: Enable chat translations if set.ellama-translation-provider
: LLM translation provider.ellama-provider
will be used if not set.ellama-coding-provider
: LLM coding tasks provider.ellama-provider
will be used if not set.ellama-summarization-provider
LLM summarization provider.ellama-provider
will be used if not set.ellama-show-quotes
: Show quotes content in chat buffer. Disabled by default.ellama-chat-display-action-function
: Display action function forellama-chat
.ellama-instant-display-action-function
: Display action function forellama-instant
.
Thanks Jeffrey Morgan for excellent project ollama. This project cannot exist without it.
Thanks zweifisch - I got some ideas from ollama.el what ollama client in Emacs can do.
Thanks Dr. David A. Kunz - I got more ideas from gen.nvim.
Thanks Andrew Hyatt for llm
library. Without it only ollama
would
be supported.
To contribute, submit a pull request or report a bug. This library is part of GNU ELPA; major contributions must be from someone with FSF papers. Alternatively, you can write a module and share it on a different archive like MELPA.