gpt-pipe

Crates.iogpt-pipe
lib.rsgpt-pipe
version0.2.0
sourcesrc
created_at2023-04-24 20:41:32.113932
updated_at2023-04-29 19:36:50.348833
descriptionGPT use with UNIX pipes
homepage
repositoryhttps://github.com/andrewgazelka/gpt-pipe
max_upload_size
id847913
size45,050
Andrew Gazelka (andrewgazelka)

documentation

README

gpt-pipe

GPT pipe

Execute GPT actions on stdin.

I am currently using this in vim to feed my entire vim buffer into ChatGPT.

nmap <leader>p :%! gpt-pipe you are a pragmatic planner. give insight/critique tasks and how I should do them. reorder tasks and explain ordering<CR>

which reorders my task list according to what GPT-4 thinks I should complete first.

To see the prompt being typed out in vim asynchronously, you can do

function! HandleOutput(job_id, data, event)
  let l:output = join(a:data, "\n")
  let l:output_lines = split(l:output, '\n', 1)
  let l:current_line = getline(line('$'))
  let l:first_line = l:current_line . l:output_lines[0]

  call setline(line('$'), l:first_line)

  if len(l:output_lines) > 1
    call append(line('$'), l:output_lines[1:])
  endif
endfunction

function! StartAsyncCommand(input)
  let l:cmd = ['gpt-pipe', 'you are a pragmatic planner. give insight/critique tasks and how I should do them. reorder tasks and explain ordering.']
  let l:job_opts = {
        \ 'on_stdout': function('HandleOutput'),
        \ 'on_stderr': function('HandleOutput'),
        \ 'in_io': 'pipe',
        \ }
  let l:job_id = jobstart(l:cmd, l:job_opts)
  call jobsend(l:job_id, a:input)
  call jobclose(l:job_id, 'stdin')
endfunction

and then map it to <leader>p with

nmap <leader>p :call StartAsyncCommand(getline(1, '$'))<CR>

Installation

cargo install gpt-pipe
Commit count: 18

cargo fmt