Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI in v3-dev branch #1154

Merged
merged 3 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
version_spec: minor
version_spec: "12.34.56"

- name: Upload Distributions
uses: actions/upload-artifact@v4
Expand Down
18 changes: 12 additions & 6 deletions packages/jupyter-ai/jupyter_ai/chat_handlers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def __init__(
self.context_providers = context_providers
self.message_interrupted = message_interrupted
self.ychat = ychat
self.indexes_by_id: Dict[str, str] = {}
self.indexes_by_id: Dict[str, int] = {}
"""
Indexes of messages in the YChat document by message ID.

Expand Down Expand Up @@ -282,17 +282,23 @@ async def _default_handle_exc(self, e: Exception, message: HumanChatMessage):
)
self.reply(response, message)

def write_message(self, body: str, id: Optional[str] = None) -> None:
"""[Jupyter Chat only] Writes a message to the YChat shared document
that this chat handler is assigned to."""
def write_message(self, body: str, id: Optional[str] = None) -> str:
"""
[Jupyter Chat only] Writes a message to the YChat shared document
that this chat handler is assigned to.

Returns the new message ID. This will be identical to the `id` argument
if passed.
"""
# TODO: remove this once `ychat` becomes a required attribute.
if not self.ychat:
return
return ""

bot = self.ychat.get_user(BOT["username"])
if not bot:
self.ychat.set_user(BOT)

index = self.indexes_by_id.get(id, None)
index = self.indexes_by_id.get(id, None) if id else None
id = id if id else str(uuid4())
new_index = self.ychat.set_message(
{
Expand Down
9 changes: 6 additions & 3 deletions packages/jupyter-ai/jupyter_ai/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@
JCOLLAB_VERSION = int(jupyter_collaboration_version[0])

if JCOLLAB_VERSION >= 3:
from jupyter_server_ydoc.utils import ( # type:ignore[import-untyped]
from jupyter_server_ydoc.utils import ( # type:ignore[import-not-found,import-untyped]
JUPYTER_COLLABORATION_EVENTS_URI,
)
else:
from jupyter_collaboration.utils import ( # type:ignore[import-untyped]
from jupyter_collaboration.utils import ( # type:ignore[import-not-found,import-untyped]
JUPYTER_COLLABORATION_EVENTS_URI,
)

Expand Down Expand Up @@ -294,6 +294,7 @@ async def get_chat(self, room_id: str) -> Optional[YChat]:
if room_id in self.ychats_by_room:
return self.ychats_by_room[room_id]

assert self.serverapp
if JCOLLAB_VERSION >= 3:
collaboration = self.serverapp.web_app.settings["jupyter_server_ydoc"]
document = await collaboration.get_document(room_id=room_id, copy=False)
Expand Down Expand Up @@ -509,9 +510,11 @@ def _init_chat_handlers(

TODO: Make `ychat` required once Jupyter Chat migration is complete.
"""
assert self.serverapp

eps = entry_points()
chat_handler_eps = eps.select(group="jupyter_ai.chat_handlers")
chat_handlers = {}
chat_handlers: Dict[str, BaseChatHandler] = {}
chat_handler_kwargs = {
"log": self.log,
"config_manager": self.settings["jai_config_manager"],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading