Skip to content

Instantly share code, notes, and snippets.

@htlin222
Created February 18, 2023 12:39
Show Gist options
  • Save htlin222/21d50e343e6d280079579ce1a17c9994 to your computer and use it in GitHub Desktop.
Save htlin222/21d50e343e6d280079579ce1a17c9994 to your computer and use it in GitHub Desktop.
call a open function

function! ChatGPTTitle() let text = substitute(@", '\n', ' ', 'g') " Replace newlines with spaces let response = system('curl -X POST -H "Content-Type: application/json" -d '{"text": "' . text . '", "model": "text-babbage-001"}' https://api.openai.com/v1/engines/davinci-codex/completions') let json = json_decode(response) let title = json['choices'][0]['text'] put = "### " . title endfunction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment