-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathollama.lua
96 lines (95 loc) · 2.74 KB
/
ollama.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
local function code_example_md(lang, code, use_start)
local language_prefix_md = "```" .. lang .. "\n"
if use_start then
return language_prefix_md .. code .. "\n```" .. "\n\n" .. language_prefix_md
else
return language_prefix_md .. code .. "\n```"
end
end
return {
"nomnivore/ollama.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
},
-- All the user commands added by the plugin
cmd = { "Ollama", "OllamaModel", "OllamaServe", "OllamaServeStop" },
keys = {
{
"<leader>oo",
":<c-u>lua require('ollama').prompt()<cr>",
desc = "ollama prompt",
mode = { "n", "v" },
},
{
"<leader>oG",
":<c-u>lua require('ollama').prompt('Generate_Code')<cr>",
desc = "ollama Generate Code",
mode = { "n", "v" },
},
{
"<leader>oR",
":<c-u>lua require('ollama').prompt('Raw')<cr>",
desc = "ollama Raw input",
mode = { "n", "v" },
},
},
opts = {
model = "qwen2.5-coder:14b",
url = "http://127.0.0.1:11434",
serve = {
on_start = false,
command = "ollama",
args = { "serve" },
stop_command = "pkill",
stop_args = { "-SIGTERM", "ollama" },
},
prompts = {
PEP484_docstrings = {
prompt = {
"Reformat the given function(s) with PEP 484 type annotations and corresponding docstring (numpy format).",
"\n```python\n$sel```\n",
"\nProvide output in the form",
"\n\n",
code_example_md("python", "<code>"),
},
input_label = " ",
action = "display_replace",
},
Python_module_docstring = {
prompt = "Write a module docstring for the given module that describes what the script/lib does.",
input_label = " ",
action = "display_replace",
},
Lua_typehints = {
prompt = {
"Add type hints to the given $ftype code:\n\n",
code_example_md("$ftype", "$sel"),
"in the form:",
"\n\n```$ftype\n---@type integer\nlocal x = 3\n```",
},
input_label = " ",
action = "display_replace",
},
Generate_Code = false,
Modify_Code = {
prompt = "$input\n\n"
.. "Respond in this format:\n"
.. code_example_md("$ftype", "code", false) --- Used for stripping out the code block
.. "\n\n"
.. code_example_md("$ftype", "$sel", true),
input_label = "Instruction: ",
action = "display_replace",
},
Comments_Inline = {
prompt = "Rewrite the code, adding terse inline comments that add information about the core functionality intended.\n"
.. "Do not change the code - even if it is obscure!\n\n"
.. "Respond in this format:\n\n" --- Used for stripping out the code block
.. code_example_md("$ftype", "code", false) --- Used for stripping out the code block
.. "\n\n"
.. code_example_md("$ftype", "$sel", true),
input_label = " ",
action = "display_replace",
},
},
},
}