Skip to content

Commit

Permalink
pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dlqqq committed Dec 20, 2024
1 parent 1918058 commit e195478
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions packages/jupyter-ai/jupyter_ai/chat_handlers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
)
from jupyter_ai_magics import Persona
from jupyter_ai_magics.providers import BaseProvider
from jupyterlab_chat.models import User, NewMessage, Message as YMessage
from jupyterlab_chat.models import Message as YMessage
from jupyterlab_chat.models import NewMessage, User
from jupyterlab_chat.ychat import YChat
from langchain.pydantic_v1 import BaseModel
from langchain_core.messages import AIMessageChunk
Expand Down Expand Up @@ -292,15 +293,18 @@ def write_message(self, body: str, stream_id: Optional[str] = None) -> str:
bot = self.ychat.get_user(BOT["username"])
if not bot:
self.ychat.set_user(User(**BOT))

if stream_id:
self.ychat.update_message(YMessage(
body=body,
id=stream_id,
time=time.time(),
sender=BOT["username"],
raw_time=False,
), append=True)
self.ychat.update_message(
YMessage(
body=body,
id=stream_id,
time=time.time(),
sender=BOT["username"],
raw_time=False,
),
append=True,
)
id = stream_id
else:
id = self.ychat.add_message(NewMessage(body=body, sender=BOT["username"]))
Expand Down

0 comments on commit e195478

Please sign in to comment.