Idea: automatically update `ellama-assistant-nick` based on the selected model
First of all, thanks a lot for your work on this package. I had a small annoyance when I was reading back old logs: I couldn't tell which LLM I had talked to (I use more than one). I thought about how to address this and got an idea: what if we change ellama-assistant-nick to reflect the name of the provider? Unfortunately, I could not find an elegant way to do it. I tried to make an advice but was way too convoluted, so I modified ellama-provider-select like this:
(defun ellama-provider-select ()
"Select ellama provider."
(interactive)
(let* ((ollama-binary (executable-find ellama-ollama-binary))
(providers (append
`(("default model" . ellama-provider)
,(if (and ollama-binary
(file-exists-p ollama-binary))
'("ollama model" . (ellama-get-ollama-local-model))))
ellama-providers))
(variants (mapcar #'car providers))
(model-name (completing-read "Select model: " variants)))
(setq ellama-provider
(eval (alist-get
model-name
providers nil nil #'string=)))
(setq ellama--current-session-id nil)
(setq ellama-assistant-nick model-name)))
As a result, every time the user picks a new model, ellama-assistant-nick takes on the corresponding value. To be more precise, if you define your providers like this:
(setopt ellama-providers '(("Mistral Nemo" . (make-llm-ollama
:chat-model "mistral-nemo:12b-instruct-2407-q4_K_M"
:embedding-model "mistral-nemo:12b-instruct-2407:q4_K_M"))
("Gemma2 2B" . (make-llm-ollama
:chat-model "gemma2:2b-instruct-q8_0"
:embedding-model "gemma2:2b-instruct-q8_0"))))
And if you pick "Mistral Nemo", then ellama-assistant-nick will take on the value of "Mistral Nemo".
Let me know what you think and if you'd maybe consider integrating such functionality into the package.
If you're fine with using regexp replacements instead of setting pretty names manually in ellama-providers (in your case I'd get "Mistral Nemo" and "Gemma2"), you could add an :after advice to ellama-provider-select and get the name from llm-name.
Here's my version. The advice only runs when the provider is changed, so I still need to set the default name to match the default provider.
(use-package ellama
:bind (("C-c e" . ellama-transient-main-menu)
:map ellama-session-mode-map
("C-c C-c" . ellama-chat-send-last-message))
:custom
(ellama-user-nick user-full-name)
(ellama-assistant-nick "Gemma2")
:config
(require 'llm-ollama)
(setq ellama-provider (make-llm-ollama :chat-model "gemma2" :embedding-model "gemma2"))
(defun advice-ellama-set-assistant-nick ()
"Set assistant name based on the current provider."
(setq ellama-assistant-nick (capitalize
(replace-regexp-in-string
"-" " "
(replace-regexp-in-string
":.*$" ""
(llm-name ellama-provider))))))
(advice-add 'ellama-provider-select :after 'advice-ellama-set-assistant-nick))