Team Ai
Apppublic

KBaba7/llama.cpp

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
0likes
llm.vim29 linesDownload Raw Back to examples
1" Basic plugin example2 3function! Llm()4 5  let url = "http://127.0.0.1:8080/completion"6 7  " Get the content of the current buffer8  let buffer_content = join(getline(1, '$'), "\n")9 10  " Create the JSON payload11  let json_payload = {"temp":0.72,"top_k":100,"top_p":0.73,"repeat_penalty":1.100000023841858,"n_predict":256,"stop": ["\n\n\n"],"stream": v:false}12  let json_payload.prompt = buffer_content13 14  " Define the curl command15  let curl_command = 'curl -k -s -X POST -H "Content-Type: application/json" -d @- ' . url16  let response = system(curl_command, json_encode(json_payload))17 18  " Extract the content field from the response19  let content = json_decode(response).content20 21  let split_newlines = split(content, '\n', 1)22 23  " Insert the content at the cursor position24  call setline(line('.'), [ getline('.') . split_newlines[0] ] + split_newlines[1:])25endfunction26 27command! Llm call Llm()28noremap <F2> :Llm<CR>29