Git Product home page Git Product logo

gen.nvim's Introduction

ollama.nvim

Generate text using LLMs with customizable prompts

Requires

Usage

Use command Ollama to generate text based on predefined and customizable prompts. If Ollama is not running, it is automatically started.

Example key maps:

vim.keymap.set('v', '<leader>]', ':Ollama<CR>')
vim.keymap.set('n', '<leader>]', ':Ollama<CR>')

You can also directly invoke it with a predefined or a custom prompt:

vim.keymap.set('v', '<leader>]', ':Ollama Enhance_Grammar_Spelling<CR>')

Use command OllamaModel to show locally available models and change the default model for this session.

Setup with lazy.nvim

{
    "sgelb/ollama.nvim"
	cmd = { "Ollama", "OllamaModel" },
	dependencies = {
		{ "nvim-lua/plenary.nvim" },
	opts = {
		default_model = "codellama:7b",
        -- custom prompts
		prompts = {
			UnitTest = {
				prompt = "Write unit tests for the following code. Output the result in the format ```$filetype\n...\n```:\n```$filetype\n$text\n```",
				replace = false,
				extract = "```$filetype\n(.-)```",
			},
		},
	},
}

Options

Predefined prompts are available threquire('ollama').prompts, you can enhance or modify them.

Example:

require('ollama').prompts['Elaborate_Text'] = {
  prompt = "Elaborate the following text:\n$text",
  replace = true
}

You can use the following properties per prompt:

  • prompt: Prompt which can use the following placeholders:
    • $text: Visually selected text
    • $filetype: Filetype of the buffer (e.g. javascript)
    • $input: Additional user input
  • replace: true if the selected text shall be replaced with the generated output
  • extract: Regular expression used to extract the generated result

You can change the model with

require('ollama').model = 'your_model' -- default 'mistal:instruct'

Here are all available models.

You can also change the complete command with

require('ollama').command = 'your command' -- default 'ollama run $model $prompt'

You can use the placeholders $model and $prompt.

gen.nvim's People

Contributors

david-kunz avatar sgelb avatar alaaibrahim avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.