aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorGeorgi Gerganov <ggerganov@gmail.com>2023-08-08 15:05:30 +0300
committerGeorgi Gerganov <ggerganov@gmail.com>2023-08-08 15:06:18 +0300
commite7f94d6fdc83b41ba449b4b8c80821673dd12ffc (patch)
tree5e075048cb96962e6ec6df9ffb4523a664fcdb4b /examples
parent2d7baaf50f3277e65cf71071f61ea34823d14c30 (diff)
vim : bring back simple llm.vim example
Diffstat (limited to 'examples')
-rw-r--r--examples/llm.vim25
1 files changed, 25 insertions, 0 deletions
diff --git a/examples/llm.vim b/examples/llm.vim
new file mode 100644
index 0000000..473e007
--- /dev/null
+++ b/examples/llm.vim
@@ -0,0 +1,25 @@
+" Basic plugin example
+
+function! Llm()
+
+ let url = "http://127.0.0.1:8080/completion"
+
+ " Get the content of the current buffer
+ let buffer_content = join(getline(1, '$'), "\n")
+
+ " Create the JSON payload
+ let json_payload = {"temp":0.72,"top_k":100,"top_p":0.73,"repeat_penalty":1.100000023841858,"n_predict":10,"stream": v:false}
+ let json_payload.prompt = buffer_content
+
+ " Define the curl command
+ let curl_command = 'curl -k -s -X POST -H "Content-Type: application/json" -d @- ' . url
+ let response = system(curl_command, json_encode(json_payload))
+
+ " Extract the content field from the response
+ let content = json_decode(response).content
+
+ " Insert the content at the cursor position
+ call setline(line('.'), getline('.') . content)
+endfunction
+
+command! Llm call Llm()