Ask the AutoSuggester from history to delegate to ask an LLM for completion This will first make sure that the current buffer have _MIN_LINES (7) available lines to insert the LLM completion Provisional as of 8.32, may change without warnings
(event: KeyPressEvent)
| 439 | |
| 440 | |
| 441 | async def llm_autosuggestion(event: KeyPressEvent): |
| 442 | """ |
| 443 | Ask the AutoSuggester from history to delegate to ask an LLM for completion |
| 444 | |
| 445 | This will first make sure that the current buffer have _MIN_LINES (7) |
| 446 | available lines to insert the LLM completion |
| 447 | |
| 448 | Provisional as of 8.32, may change without warnings |
| 449 | |
| 450 | """ |
| 451 | _MIN_LINES = 5 |
| 452 | provider = get_ipython().auto_suggest |
| 453 | if not isinstance(provider, NavigableAutoSuggestFromHistory): |
| 454 | return |
| 455 | doc = event.current_buffer.document |
| 456 | lines_to_insert = max(0, _MIN_LINES - doc.line_count + doc.cursor_position_row) |
| 457 | for _ in range(lines_to_insert): |
| 458 | event.current_buffer.insert_text("\n", move_cursor=False, fire_event=False) |
| 459 | |
| 460 | await provider._trigger_llm(event.current_buffer) |
| 461 | |
| 462 | |
| 463 | def accept_or_jump_to_end(event: KeyPressEvent): |
searching dependent graphs…