Skip to content

Commit

Permalink
Fix jupyter_collaboration version
Browse files Browse the repository at this point in the history
Co-authored-by: david qiu <[email protected]>
  • Loading branch information
brichet and dlqqq committed Dec 3, 2024
1 parent ed334de commit 02cedfd
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/jupyter-ai/jupyter_ai/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
from jupyter_ai.models import HumanChatMessage
from jupyter_ai_magics import BaseProvider, JupyternautPersona
from jupyter_ai_magics.utils import get_em_providers, get_lm_providers
from jupyter_collaboration.utils import ( # type:ignore[import-untyped]
JUPYTER_COLLABORATION_EVENTS_URI,
)
from jupyter_events import EventLogger
from jupyter_server.extension.application import ExtensionApp
from jupyter_server.utils import url_path_join
Expand Down Expand Up @@ -58,11 +55,16 @@
os.path.join(os.path.dirname(__file__), "static", "jupyternaut.svg")
)

JCOLLAB_VERSION = int(jupyter_collaboration_version[0])

if int(jupyter_collaboration_version[0]) >= 3:
COLLAB_VERSION = 3
if JCOLLAB_VERSION >= 3:
from jupyter_server_ydoc.utils import ( # type:ignore[import-untyped]
JUPYTER_COLLABORATION_EVENTS_URI,
)
else:
COLLAB_VERSION = 2
from jupyter_collaboration.utils import ( # type:ignore[import-untyped]
JUPYTER_COLLABORATION_EVENTS_URI,
)

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

async def get_chat(self, room_id: str) -> Optional[YChat]:
if COLLAB_VERSION == 3:
if JCOLLAB_VERSION >= 3:
collaboration = self.serverapp.web_app.settings["jupyter_server_ydoc"]
document = await collaboration.get_document(room_id=room_id, copy=False)
else:
Expand Down

0 comments on commit 02cedfd

Please sign in to comment.