Skip to content

Commit

Permalink
Fix CI in v3-dev branch (#1154)
Browse files Browse the repository at this point in the history
* fix check release by bumping to impossible version

* fix types

* Update Playwright Snapshots

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
dlqqq and github-actions[bot] authored Dec 11, 2024
1 parent a0b8e84 commit e52aedf
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
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.

0 comments on commit e52aedf

Please sign in to comment.