MCPcopy Index your code
hub / github.com/ipython/ipython / llm_autosuggestion

Function llm_autosuggestion

IPython/terminal/shortcuts/auto_suggest.py:441–460  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

439
440
441async 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
463def accept_or_jump_to_end(event: KeyPressEvent):

Callers 1

test_llm_autosuggestionFunction · 0.90

Calls 2

get_ipythonFunction · 0.90
_trigger_llmMethod · 0.80

Tested by 1

test_llm_autosuggestionFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…