llm.vim 772 B

1234567891011121314151617181920212223
  1. function! Llm()
  2. let url = "http://127.0.0.1:8080/completion"
  3. " Get the content of the current buffer
  4. let buffer_content = join(getline(1, '$'), "\n")
  5. " Create the JSON payload
  6. let json_payload = {"temp":0.72,"top_k":100,"top_p":0.73,"repeat_penalty":1.100000023841858,"n_predict":10,"stream": v:false}
  7. let json_payload.prompt = buffer_content
  8. " Define the curl command
  9. let curl_command = 'curl -k -s -X POST -H "Content-Type: application/json" -d @- ' . url
  10. let response = system(curl_command, json_encode(json_payload))
  11. " Extract the content field from the response
  12. let content = json_decode(response).content
  13. " Insert the content at the cursor position
  14. call setline(line('.'), getline('.') . content)
  15. endfunction
  16. command! Llm call Llm()