s-kostyaev / ellama

Ellama is a tool for interacting with large language models from Emacs.
GNU General Public License v3.0
348 stars 25 forks source link

Feature request: make "ollama-binary" accept the basename of the executable #109

Open hab25 opened 2 months ago

hab25 commented 2 months ago

I.e. have

(setopt ollama-binary "ollama")

work.

This supports the use-case where the absolute path to ollama changes at runtime. E.g. when using something like https://github.com/astoff/buffer-env.

With this change, ellama will be aware each time the user (implicitly) changes their desired ollama by updating their exec-path variable.

I think the only change needed is to remove this check: https://github.com/s-kostyaev/ellama/blob/6e6ec8e28b8ce32ff207b1b026aaaeddc1bd8239/ellama.el#L1123C49-L1123C85

s-kostyaev commented 2 months ago

We cant remove this check. It prevents errors for users without ollama installed. It should work out of the box if you update not only exec-path but also ellama-ollama-binary. This code will work for users without configured exec-path if they set ellama-ollama-binary. Not sure if we can handle correctly all the cases.

s-kostyaev commented 2 months ago

Also, is this real case or imaginable? I mean why user will have different ollama binaries?

hab25 commented 2 months ago

We cant remove this check. It prevents errors for users without ollama installed.

I see. If that is its only purpose, then, instead of #'file-exists-p, #'executable-find can be used (note that it works for both basenames and absolute paths).

Also, is this real case or imaginable?

Having multiple ollama binaries is is not currently a use case for me.

The use case that prompted me to create this issue is that I have created an abstraction that helps me programatically assert that the system dependendies expected by the Emacs packages I use can be found in known good locations. Among all these Emacs packages, ollama is the only one that didn't accept the basename, only the absolute path. If I didn't have to support this ollama special case, I would be able to save on some special-case code.

I mean why user will have different ollama binaries?

One example is if a user wants to use both the latest ollama commit from the master branch as well as the latest git tag, because sometimes they prefer latest features and sometimes they prefer stability.

Another example is when using using direnv and ollama in many software projects, each project pointing to their own desired version of ollama.

hab25 commented 2 months ago

If I didn't have to support this ollama special case, I would be able to save on some special-case code.

(another, more important reason, is that I think the approach that direnv allows is a best-practice and almost always a worthwhile practice for any software project, and so ellama should support that)