|
| 1 | +" vim: ts=4 sts=4 expandtab |
1 | 2 | " colors (adjust to your liking) |
2 | 3 | highlight llama_hl_hint guifg=#ff772f ctermfg=202 |
3 | 4 | highlight llama_hl_info guifg=#77ff2f ctermfg=119 |
@@ -318,17 +319,22 @@ function! s:ring_update() |
318 | 319 | \ "--request", "POST", |
319 | 320 | \ "--url", g:llama_config.endpoint, |
320 | 321 | \ "--header", "Content-Type: application/json", |
321 | | - \ "--data", l:request |
| 322 | + \ "--data", "@-", |
322 | 323 | \ ] |
323 | 324 | if exists ("g:llama_config.api_key") && len("g:llama_config.api_key") > 0 |
324 | 325 | call extend(l:curl_command, ['--header', 'Authorization: Bearer ' .. g:llama_config.api_key]) |
325 | 326 | endif |
326 | 327 |
|
327 | 328 | " no callbacks because we don't need to process the response |
328 | 329 | if s:ghost_text_nvim |
329 | | - call jobstart(l:curl_command, {}) |
| 330 | + let jobid = jobstart(l:curl_command, {}) |
| 331 | + call chansend(jobid, l:request) |
| 332 | + call chanclose(jobid, 'stdin') |
330 | 333 | elseif s:ghost_text_vim |
331 | | - call job_start(l:curl_command, {}) |
| 334 | + let jobid = job_start(l:curl_command, {}) |
| 335 | + let channel = job_getchannel(jobid) |
| 336 | + call ch_sendraw(channel, l:request) |
| 337 | + call ch_close_in(channel) |
332 | 338 | endif |
333 | 339 | endfunction |
334 | 340 |
|
@@ -444,7 +450,7 @@ function! llama#fim(is_auto, cache) abort |
444 | 450 | \ "--request", "POST", |
445 | 451 | \ "--url", g:llama_config.endpoint, |
446 | 452 | \ "--header", "Content-Type: application/json", |
447 | | - \ "--data", l:request |
| 453 | + \ "--data", "@-", |
448 | 454 | \ ] |
449 | 455 | if exists ("g:llama_config.api_key") && len("g:llama_config.api_key") > 0 |
450 | 456 | call extend(l:curl_command, ['--header', 'Authorization: Bearer ' .. g:llama_config.api_key]) |
@@ -504,11 +510,17 @@ function! llama#fim(is_auto, cache) abort |
504 | 510 | \ 'on_exit': function('s:fim_on_exit'), |
505 | 511 | \ 'stdout_buffered': v:true |
506 | 512 | \ }) |
| 513 | + call chansend(s:current_job, l:request) |
| 514 | + call chanclose(s:current_job, 'stdin') |
507 | 515 | elseif s:ghost_text_vim |
508 | 516 | let s:current_job = job_start(l:curl_command, { |
509 | 517 | \ 'out_cb': function('s:fim_on_stdout', [l:hash, a:cache, s:pos_x, s:pos_y, a:is_auto]), |
510 | 518 | \ 'exit_cb': function('s:fim_on_exit') |
511 | 519 | \ }) |
| 520 | + |
| 521 | + let channel = job_getchannel(s:current_job) |
| 522 | + call ch_sendraw(channel, l:request) |
| 523 | + call ch_close_in(channel) |
512 | 524 | endif |
513 | 525 | endif |
514 | 526 |
|
|
0 commit comments