Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d4d1901

Browse files
committed
dont trigger numpy import
1 parent 1e45ed1 commit d4d1901

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

IPython/terminal/shortcuts/auto_suggest.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@
2424

2525
from .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

3428
def _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,

0 commit comments

Comments
 (0)