File tree Expand file tree Collapse file tree
IPython/terminal/shortcuts Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2424
2525from .filters import pass_through
2626
27- try :
28- import jupyter_ai_magics
29- import jupyter_ai .completions .models as jai_models
30- except ModuleNotFoundError :
31- jai_models = None
32-
3327
3428def _get_query (document : Document ):
3529 return document .lines [document .cursor_position_row ]
@@ -325,6 +319,11 @@ async def _trigger_llm(self, buffer) -> None:
325319 If there is a currently running llm task, it will cancel it.
326320 """
327321 # we likely want to store the current cursor position, and cancel if the cursor has moved.
322+ try :
323+ import jupyter_ai_magics
324+ import jupyter_ai .completions .models as jai_models
325+ except ModuleNotFoundError :
326+ jai_models = None
328327 if not self ._llm_provider :
329328 warnings .warn ("No LLM provider found, cannot trigger LLM completions" )
330329 return
@@ -374,6 +373,11 @@ async def _trigger_llm_core(self, buffer: Buffer):
374373 stream_inline_completions, I'm not sure it is the case for all
375374 providers.
376375 """
376+ try :
377+ import jupyter_ai_magics
378+ import jupyter_ai .completions .models as jai_models
379+ except ModuleNotFoundError :
380+ jai_models = None
377381
378382 request = jai_models .InlineCompletionRequest (
379383 number = 0 ,
You can’t perform that action at this time.
0 commit comments