Skip to content

Commit 02cedfd

Browse files
brichetdlqqq
andcommitted
Fix jupyter_collaboration version
Co-authored-by: david qiu <[email protected]>
1 parent ed334de commit 02cedfd

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

packages/jupyter-ai/jupyter_ai/extension.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
from jupyter_ai.models import HumanChatMessage
1313
from jupyter_ai_magics import BaseProvider, JupyternautPersona
1414
from jupyter_ai_magics.utils import get_em_providers, get_lm_providers
15-
from jupyter_collaboration.utils import ( # type:ignore[import-untyped]
16-
JUPYTER_COLLABORATION_EVENTS_URI,
17-
)
1815
from jupyter_events import EventLogger
1916
from jupyter_server.extension.application import ExtensionApp
2017
from jupyter_server.utils import url_path_join
@@ -58,11 +55,16 @@
5855
os.path.join(os.path.dirname(__file__), "static", "jupyternaut.svg")
5956
)
6057

58+
JCOLLAB_VERSION = int(jupyter_collaboration_version[0])
6159

62-
if int(jupyter_collaboration_version[0]) >= 3:
63-
COLLAB_VERSION = 3
60+
if JCOLLAB_VERSION >= 3:
61+
from jupyter_server_ydoc.utils import ( # type:ignore[import-untyped]
62+
JUPYTER_COLLABORATION_EVENTS_URI,
63+
)
6464
else:
65-
COLLAB_VERSION = 2
65+
from jupyter_collaboration.utils import ( # type:ignore[import-untyped]
66+
JUPYTER_COLLABORATION_EVENTS_URI,
67+
)
6668

6769
# The BOT currently has a fixed username, because this username is used has key in chats,
6870
# it needs to constant. Do we need to change it ?
@@ -271,7 +273,7 @@ async def connect_chat(
271273
chat.ymessages.observe(callback)
272274

273275
async def get_chat(self, room_id: str) -> Optional[YChat]:
274-
if COLLAB_VERSION == 3:
276+
if JCOLLAB_VERSION >= 3:
275277
collaboration = self.serverapp.web_app.settings["jupyter_server_ydoc"]
276278
document = await collaboration.get_document(room_id=room_id, copy=False)
277279
else:

0 commit comments

Comments
 (0)