nomnivore / ollama.nvim

A plugin for managing and integrating your ollama workflows in neovim.
MIT License
311 stars 22 forks source link

Added dedicated code model #12

Closed gerazov closed 1 month ago

gerazov commented 7 months ago

codellama performs better than other models when asking about code. This PR enables users to optionally have a separate code_model from the default model used for general prompts.

It also adds symmetrical text based prompts to the original code based prompts. Maybe they could be trimmed :thinking:

nomnivore commented 6 months ago

At first, I liked this idea, and was working on pushing a couple fixes (for instance -- the setup function now override's all user config prompts), but as I played with it more I found some more pain points.

The OllamaModel command, for all users using default config, does effectively nothing now since all built-in prompts have their model set to the default at setup time. If we remedied this (e.g by not explicitly setting model on default "text" prompts), there still is no way to change your code model.

I totally agree that the model you want for code is likely not the same as the model you want for regular text. To solve for this, prompts (both your own, and the defaults via config overrides) can specify any model they want individually. That is part of why I want to keep default prompts lean, so that overriding with your preferences takes just a few lines of code/config.

What part of the current implementation of model overrides in Prompts leaves you wanting? Perhaps there is a difference approach we can take, or that this one could be better adapted.

As always, I appreciate your time both using & contributing to the plugin, it means a lot! To reduce the risk of any potentially wasted efforts in the future, I encourage you to reach out or open an Issue first.

gerazov commented 6 months ago

Oh - you're right! I didn't see that coming :sweat_smile:

I was overriding the default prompts in my config in the previous version. The problem with this is that all the default prompts are code based, and the default model is not a code focused one. So one would have to override all the default prompts, making their usefulness questionable.

Now you could specify the default model to be a code based one, but then you have to define text based equivalents to the code prompts. Which is fine if you want the plugin to stay code-focused (as it is currently is). I think this is a limitation, as the plugin should allow for normal prompts as well.

I made the PR so that there would be code and regular prompts offered by default. For the text ones, I didn't want to add them here, but ones that would make sense to me are the prompts used by @David-Kunz in his David-Kunz/gen.nvim, e.g.:

    Summarize = { prompt = "Summarize the following text:\n$text" },
    Enhance_Grammar_Spelling = {
        prompt = "Modify the following text to improve grammar and spelling, just output the final text without additional quotes around it:\n$text",
        replace = true,
    },
    Enhance_Wording = {
        prompt = "Modify the following text to use better wording, just output the final text without additional quotes around it:\n$text",
        replace = true,
    },
    Make_Concise = {
        prompt = "Modify the following text to make it as simple and concise as possible, just output the final text without additional quotes around it:\n$text",
        replace = true,
    },
    Make_List = {
        prompt = "Render the following text as a markdown list:\n$text",
        replace = true,
    },

I have already included them in my config, but I think they would be a nice addition to the default prompt set of ollama.nvim as well.