@@ -349,14 +349,14 @@ function! llama#fim(is_auto, cache) abort
349349 call llama#fim_cancel ()
350350
351351 " avoid sending repeated requests too fast
352- if reltimefloat ( reltime ( s: t_fim_start )) < 0.6
352+ if s: current_job != v: null
353353 if s: timer_fim != -1
354354 call timer_stop (s: timer_fim )
355355 let s: timer_fim = -1
356356 endif
357357
358358 let s: t_fim_start = reltime ()
359- let s: timer_fim = timer_start (600 , {- > llama#fim (v: true , a: cache )})
359+ let s: timer_fim = timer_start (100 , {- > llama#fim (v: true , a: cache )})
360360 return
361361 endif
362362
@@ -459,22 +459,22 @@ function! llama#fim(is_auto, cache) abort
459459 if l: cached_completion == v: null
460460 let l: past_text = l: prefix . l: prompt
461461 for i in range (10 )
462- let l: hash_txt = l: past_text [:- (2 + i )] . l: suffix
463- let l: temp_hash = sha256 (l: hash_txt )
464- if has_key (g: result_cache , l: temp_hash )
465- let l: temp_cached_completion = get (g: result_cache , l: temp_hash )
466- if l: temp_cached_completion == " "
467- break
468- endif
469- let l: response = json_decode (l: temp_cached_completion )
470- if l: response [' content' ][0 : len (l: past_text [- (1 + i ):])-1 ] !=# l: past_text [- (1 + i ):]
471- break
472- endif
473- let l: response [' content' ] = l: response [' content' ][i + 1 :]
474- let g: result_cache [l: hash ] = json_encode (l: response )
475- let l: cached_completion = g: result_cache [l: hash ]
462+ let l: hash_txt = l: past_text [:- (2 + i )] . l: suffix
463+ let l: temp_hash = sha256 (l: hash_txt )
464+ if has_key (g: result_cache , l: temp_hash )
465+ let l: temp_cached_completion = get (g: result_cache , l: temp_hash )
466+ if l: temp_cached_completion == " "
467+ break
468+ endif
469+ let l: response = json_decode (l: temp_cached_completion )
470+ if l: response [' content' ][0 : len (l: past_text [- (1 + i ):])-1 ] !=# l: past_text [- (1 + i ):]
476471 break
477472 endif
473+ let l: response [' content' ] = l: response [' content' ][i + 1 :]
474+ let g: result_cache [l: hash ] = json_encode (l: response )
475+ let l: cached_completion = g: result_cache [l: hash ]
476+ break
477+ endif
478478 endfor
479479 endif
480480 endif
0 commit comments