|
12 | 12 | from jupyter_ai.models import HumanChatMessage
|
13 | 13 | from jupyter_ai_magics import BaseProvider, JupyternautPersona
|
14 | 14 | 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 |
| -) |
18 | 15 | from jupyter_events import EventLogger
|
19 | 16 | from jupyter_server.extension.application import ExtensionApp
|
20 | 17 | from jupyter_server.utils import url_path_join
|
|
58 | 55 | os.path.join(os.path.dirname(__file__), "static", "jupyternaut.svg")
|
59 | 56 | )
|
60 | 57 |
|
| 58 | +JCOLLAB_VERSION = int(jupyter_collaboration_version[0]) |
61 | 59 |
|
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 | + ) |
64 | 64 | else:
|
65 |
| - COLLAB_VERSION = 2 |
| 65 | + from jupyter_collaboration.utils import ( # type:ignore[import-untyped] |
| 66 | + JUPYTER_COLLABORATION_EVENTS_URI, |
| 67 | + ) |
66 | 68 |
|
67 | 69 | # The BOT currently has a fixed username, because this username is used has key in chats,
|
68 | 70 | # it needs to constant. Do we need to change it ?
|
@@ -271,7 +273,7 @@ async def connect_chat(
|
271 | 273 | chat.ymessages.observe(callback)
|
272 | 274 |
|
273 | 275 | async def get_chat(self, room_id: str) -> Optional[YChat]:
|
274 |
| - if COLLAB_VERSION == 3: |
| 276 | + if JCOLLAB_VERSION >= 3: |
275 | 277 | collaboration = self.serverapp.web_app.settings["jupyter_server_ydoc"]
|
276 | 278 | document = await collaboration.get_document(room_id=room_id, copy=False)
|
277 | 279 | else:
|
|
0 commit comments