-
-
Notifications
You must be signed in to change notification settings - Fork 349
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
[v3-dev] Initial migration to jupyterlab-chat
#1043
Conversation
* Fix handler methods' parameters * Add slash commands (autocompletion) to the chat input
* Allow for stream messages * update jupyter collaborative chat dependency
* Add a menu option to open the AI settings * Remove the input option from the setting widget
* Show that the bot is writing (answering) * Update jupyter chat dependency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brichet Thanks for contributing this, and for being patient with us as we were very busy for the last few months.
I've tried to test this branch by doing a dev install with jlpm && jlpm build && jlpm dev-install
. However, I only see replies in the original Jupyter AI chat, and not chats created through jupyterlab-chat
.
Question: Do I need to do anything else to get Jupyter AI working in new chats?
Screenshot:
The server logs also include an error:
[E 2024-12-02 15:59:53.928 ServerApp] Failed to write message
Traceback (most recent call last):
File "/Users/dlq/micromamba/envs/jai3/lib/python3.11/site-packages/jupyter_collaboration/handlers.py", line 270, in send
self.write_message(message, binary=True)
File "/Users/dlq/micromamba/envs/jai3/lib/python3.11/site-packages/tornado/websocket.py", line 332, in write_message
raise WebSocketClosedError()
tornado.websocket.WebSocketClosedError
[I 2024-12-02 15:59:53.955 ServerApp] Request for Y document 'test.chat' with room ID: 41030a07-f29d-4ded-b13b-39dfda2b43bb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Completed an initial review of your PR. The changes are surprisingly small relative to the scope of this PR. Thank you for keeping the changes minimal for the sake of reviewers! 🥇
I haven't reviewed everything, but have left some questions & comments on the areas of the code I found most important.
High-level proposal: I noticed was that many of the backend changes to the Python files centered around forwarding the YChat
instance as an argument to many methods in BaseChatHandler
. Since we know for certain that we want to support multiple chats, I think it makes sense to make chat handlers non-singletons and allow multiple instances of chat handlers (one per chat). This will allow us to revert the changes to the arguments and simplify this PR.
- By making chat handlers non-singletons, each chat handler can be passed a
ychat: YChat
attribute on init, which means that chat handler methods won't require achat: YChat
argument. This is what will allow many of the Python changes to be reverted. - If this breaks some chat handlers, that's OK for now. We will improve & fix them later right before the first pre-release.
Next steps:
- Nicolas: Help verify this PR works, respond to my feedback, and tell me if you're OK with me implementing the high-level proposal above.
- David: Continue reviewing as time permits, and work on the high-level proposal above if you accept.
- Nicolas & David: Continue to work together to get this merged by the end of this week.
Sorry for this @dlqqq , my bad. EDIT: It should be fixed by now. |
Co-authored-by: david qiu <44106031+dlqqq@users.noreply.github.com>
Thanks for the review @dlqqq
Sure 👍 |
jupyterlab-chat
jupyterlab-chat
jupyterlab-chat
@brichet New PR that implements the high-level proposal I mentioned in my last review: QuantStack#9 |
* create new set of chat handlers per room * make YChat an instance attribute on BaseChatHandler * revert changes to chat handlers * pre-commit * use room_id local var Co-authored-by: Nicolas Brichet <32258950+brichet@users.noreply.github.com> --------- Co-authored-by: Nicolas Brichet <32258950+brichet@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brichet Awesome, this PR looks good to me! Of course we will want to iterate on this, but this is a great start. Thank you for your hard work thus far.
Merging into v3-dev
. 🎉
Hooray, I guess it's a good time to start working on other items from v3 roadmap? Or do you expect any other larger refactor to land soon?
|
@krassowski Hey Mike, thanks for reaching out and being so eager to help! Yes, you can absolutely feel free to collaborate on v3 with us. We welcome your contributions, and appreciate all the work you've done for Jupyter AI so far. If you are proposing a large change, I do ask that you ping me in a new issue / existing issue and provide a broad high-level outline of your proposal. If we discover in our initial discussion that there may be a better way to implement a change, then having this discussion first would save time for both of us. 🤗 The current plan is to cut a pre-release ( Hope this helps! Have a great weekend Mike, get some rest. 👋 |
I think that it worth noticing that the I'll work on "cleaning old chat" PR. |
* Backport PR #1049: Added new Anthropic Sonnet3.5 v2 models (#1050) Co-authored-by: Sanjiv Das <srdas@scu.edu> * Backport PR #1051: Added Developer documentation for streaming responses (#1058) Co-authored-by: Sanjiv Das <srdas@scu.edu> * Backport PR #1048: Implement streaming for `/fix` (#1059) Co-authored-by: Sanjiv Das <srdas@scu.edu> * Backport PR #1057: [pre-commit.ci] pre-commit autoupdate (#1060) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * Backport PR #1064: Added Ollama to the providers table in user docs (#1066) Co-authored-by: Sanjiv Das <srdas@scu.edu> * Backport PR #1056: Add examples of using Fields and EnvAuthStrategy to developer documentation (#1073) Co-authored-by: Alan Meeson <alanmeeson@users.noreply.github.com> * Backport PR #1069: Merge Anthropic language model providers (#1076) Co-authored-by: Sanjiv Das <srdas@scu.edu> * Backport PR #1068: Allow `$` to literally denote quantities of USD in chat (#1079) Co-authored-by: david qiu <david@qiu.dev> * Backport PR #1075: Fix magic commands when using non-chat providers w/ history (#1080) Co-authored-by: Alan Meeson <alanmeeson@users.noreply.github.com> * Backport PR #1077: Fix `/export` by including streamed agent messages (#1081) Co-authored-by: Mahmut CAVDAR <4072246+mcavdar@users.noreply.github.com> * Backport PR #1072: Reduced padding in cell around code icons in code toolbar (#1084) Co-authored-by: Sanjiv Das <srdas@scu.edu> * Backport PR #1087: Improve installation documentation and clarify provider dependencies (#1091) Co-authored-by: Sanjiv Das <srdas@scu.edu> * Backport PR #1092: Remove retired models and add new `Haiku-3.5` model in Anthropic (#1093) Co-authored-by: Sanjiv Das <srdas@scu.edu> * Backport PR #1094: Continue to allow `$` symbols to delimit inline math in human messages (#1095) Co-authored-by: david qiu <david@qiu.dev> * Backport PR #1097: Update `faiss-cpu` version range (#1101) Co-authored-by: david qiu <david@qiu.dev> * Backport PR #1104: Fix rendering of code blocks in JupyterLab 4.3.0+ (#1105) Co-authored-by: david qiu <david@qiu.dev> * Backport PR #1106: Catch error on non plaintext files in `@file` and reply gracefully in chat (#1110) Co-authored-by: Sanjiv Das <srdas@scu.edu> * Backport PR #1109: Bump LangChain minimum versions (#1112) Co-authored-by: david qiu <david@qiu.dev> * Backport PR #1119: Downgrade spurious 'error' logs (#1124) Co-authored-by: ctcjab <joshua.bronson@chicagotrading.com> * Backport PR #1127: Removes outdated OpenAI models and adds new ones (#1130) Co-authored-by: Sanjiv Das <srdas@scu.edu> * Backport PR #1131: [pre-commit.ci] pre-commit autoupdate (#1132) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * Backport PR #1125: Update model fields immediately on save (#1133) Co-authored-by: david qiu <david@qiu.dev> * Backport PR #1139: Fix install step in CI (#1140) Co-authored-by: david qiu <david@qiu.dev> * Backport PR #1129: Fix JSON serialization error in Ollama models (#1141) Co-authored-by: Mr.W <janus.choy@gmail.com> * Backport PR #1137: Update completion model fields immediately on save (#1142) Co-authored-by: david qiu <david@qiu.dev> * [v3-dev] Initial migration to `jupyterlab-chat` (#1043) * Very first version of the AI working in jupyterlab_collaborative_chat * Allows both collaborative and regular chat to work with AI * handle the help message in the chat too * Autocompletion (#2) * Fix handler methods' parameters * Add slash commands (autocompletion) to the chat input * Stream messages (#3) * Allow for stream messages * update jupyter collaborative chat dependency * AI settings (#4) * Add a menu option to open the AI settings * Remove the input option from the setting widget * pre-commit * linting * Homogeneize typing for optional arguments * Fix import * Showing that the bot is writing (answering) (#5) * Show that the bot is writing (answering) * Update jupyter chat dependency * Some typing * Update extension to jupyterlab_chat (0.6.0) (#8) * Fix linting * Remove try/except to import jupyterlab_chat (not optional anymore), and fix typing * linter * Python unit tests * Fix typing * lint * Fix lint and mypy all together * Fix web_app settings accessor * Fix jupyter_collaboration version Co-authored-by: david qiu <44106031+dlqqq@users.noreply.github.com> * Remove unecessary try/except * Dedicate one set of chat handlers per room (#9) * create new set of chat handlers per room * make YChat an instance attribute on BaseChatHandler * revert changes to chat handlers * pre-commit * use room_id local var Co-authored-by: Nicolas Brichet <32258950+brichet@users.noreply.github.com> --------- Co-authored-by: Nicolas Brichet <32258950+brichet@users.noreply.github.com> --------- Co-authored-by: david qiu <44106031+dlqqq@users.noreply.github.com> Co-authored-by: david qiu <david@qiu.dev> * Backport PR #1134: Improve user messaging and documentation for Cross-Region Inference on Amazon Bedrock (#1143) Co-authored-by: Sanjiv Das <srdas@scu.edu> * Backport PR #1136: Add base API URL field for Ollama and OpenAI embedding models (#1149) Co-authored-by: Sanjiv Das <srdas@scu.edu> * [v3-dev] Remove `/export`, `/clear`, and `/fix` (#1148) * remove /export * remove /clear * remove /fix * Fix CI in `v3-dev` branch (#1154) * 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> * [v3-dev] Dedicate one LangChain history object per chat (#1151) * dedicate a separate LangChain history object per chat * pre-commit * fix mypy * Backport PR #1160: Trigger update snapshots based on commenter's role (#1161) Co-authored-by: david qiu <david@qiu.dev> * Backport PR #1155: Fix code output format in IPython (#1162) Co-authored-by: Divyansh Choudhary <divyanshchoudhary99@gmail.com> * Backport PR #1158: Update `/generate` to not split classes & functions across cells (#1164) Co-authored-by: Sanjiv Das <srdas@scu.edu> * Remove v2 frontend components (#1156) * First pass to remove the front end chat * Remove code-toolbar by using a simplified markdown renderer in settings * Remove chat-message-menu (should be ported in jupyter-chat) * Remove chat handler * Follow up 'Remove chat-message-menu (should be ported in jupyter-chat)' commit * Clean package.json * Remove UI tests * Remove the generative AI menu * Remove unused components * run yarn dedupe --------- Co-authored-by: David L. Qiu <david@qiu.dev> * Upgrade to `jupyterlab-chat>=0.7.0` (#1166) * upgrade to jupyterlab-chat 0.7.0 * pre-commit * upgrade to @jupyter/chat ^0.7.0 in frontend * Remove v2 backend components (#1168) * remove v2 llm memory, implement ReplyStream * remove v2 websockets & REST handlers * remove unused v2 data models * fix slash command autocomplete * fix unit tests * remove unused _learned context provider * fix mypy * pre-commit * fix optional k arg in YChatHistory * bump jupyter chat to 0.7.1 to fix Python 3.9 tests * revert accidentally breaking /learn --------- Co-authored-by: Lumberbot (aka Jack) <39504233+meeseeksmachine@users.noreply.github.com> Co-authored-by: Sanjiv Das <srdas@scu.edu> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Alan Meeson <alanmeeson@users.noreply.github.com> Co-authored-by: Mahmut CAVDAR <4072246+mcavdar@users.noreply.github.com> Co-authored-by: ctcjab <joshua.bronson@chicagotrading.com> Co-authored-by: Mr.W <janus.choy@gmail.com> Co-authored-by: Nicolas Brichet <32258950+brichet@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Divyansh Choudhary <divyanshchoudhary99@gmail.com>
* Backport PR jupyterlab#1049: Added new Anthropic Sonnet3.5 v2 models (jupyterlab#1050) Co-authored-by: Sanjiv Das <srdas@scu.edu> * Backport PR jupyterlab#1051: Added Developer documentation for streaming responses (jupyterlab#1058) Co-authored-by: Sanjiv Das <srdas@scu.edu> * Backport PR jupyterlab#1048: Implement streaming for `/fix` (jupyterlab#1059) Co-authored-by: Sanjiv Das <srdas@scu.edu> * Backport PR jupyterlab#1057: [pre-commit.ci] pre-commit autoupdate (jupyterlab#1060) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * Backport PR jupyterlab#1064: Added Ollama to the providers table in user docs (jupyterlab#1066) Co-authored-by: Sanjiv Das <srdas@scu.edu> * Backport PR jupyterlab#1056: Add examples of using Fields and EnvAuthStrategy to developer documentation (jupyterlab#1073) Co-authored-by: Alan Meeson <alanmeeson@users.noreply.github.com> * Backport PR jupyterlab#1069: Merge Anthropic language model providers (jupyterlab#1076) Co-authored-by: Sanjiv Das <srdas@scu.edu> * Backport PR jupyterlab#1068: Allow `$` to literally denote quantities of USD in chat (jupyterlab#1079) Co-authored-by: david qiu <david@qiu.dev> * Backport PR jupyterlab#1075: Fix magic commands when using non-chat providers w/ history (jupyterlab#1080) Co-authored-by: Alan Meeson <alanmeeson@users.noreply.github.com> * Backport PR jupyterlab#1077: Fix `/export` by including streamed agent messages (jupyterlab#1081) Co-authored-by: Mahmut CAVDAR <4072246+mcavdar@users.noreply.github.com> * Backport PR jupyterlab#1072: Reduced padding in cell around code icons in code toolbar (jupyterlab#1084) Co-authored-by: Sanjiv Das <srdas@scu.edu> * Backport PR jupyterlab#1087: Improve installation documentation and clarify provider dependencies (jupyterlab#1091) Co-authored-by: Sanjiv Das <srdas@scu.edu> * Backport PR jupyterlab#1092: Remove retired models and add new `Haiku-3.5` model in Anthropic (jupyterlab#1093) Co-authored-by: Sanjiv Das <srdas@scu.edu> * Backport PR jupyterlab#1094: Continue to allow `$` symbols to delimit inline math in human messages (jupyterlab#1095) Co-authored-by: david qiu <david@qiu.dev> * Backport PR jupyterlab#1097: Update `faiss-cpu` version range (jupyterlab#1101) Co-authored-by: david qiu <david@qiu.dev> * Backport PR jupyterlab#1104: Fix rendering of code blocks in JupyterLab 4.3.0+ (jupyterlab#1105) Co-authored-by: david qiu <david@qiu.dev> * Backport PR jupyterlab#1106: Catch error on non plaintext files in `@file` and reply gracefully in chat (jupyterlab#1110) Co-authored-by: Sanjiv Das <srdas@scu.edu> * Backport PR jupyterlab#1109: Bump LangChain minimum versions (jupyterlab#1112) Co-authored-by: david qiu <david@qiu.dev> * Backport PR jupyterlab#1119: Downgrade spurious 'error' logs (jupyterlab#1124) Co-authored-by: ctcjab <joshua.bronson@chicagotrading.com> * Backport PR jupyterlab#1127: Removes outdated OpenAI models and adds new ones (jupyterlab#1130) Co-authored-by: Sanjiv Das <srdas@scu.edu> * Backport PR jupyterlab#1131: [pre-commit.ci] pre-commit autoupdate (jupyterlab#1132) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * Backport PR jupyterlab#1125: Update model fields immediately on save (jupyterlab#1133) Co-authored-by: david qiu <david@qiu.dev> * Backport PR jupyterlab#1139: Fix install step in CI (jupyterlab#1140) Co-authored-by: david qiu <david@qiu.dev> * Backport PR jupyterlab#1129: Fix JSON serialization error in Ollama models (jupyterlab#1141) Co-authored-by: Mr.W <janus.choy@gmail.com> * Backport PR jupyterlab#1137: Update completion model fields immediately on save (jupyterlab#1142) Co-authored-by: david qiu <david@qiu.dev> * [v3-dev] Initial migration to `jupyterlab-chat` (jupyterlab#1043) * Very first version of the AI working in jupyterlab_collaborative_chat * Allows both collaborative and regular chat to work with AI * handle the help message in the chat too * Autocompletion (jupyterlab#2) * Fix handler methods' parameters * Add slash commands (autocompletion) to the chat input * Stream messages (jupyterlab#3) * Allow for stream messages * update jupyter collaborative chat dependency * AI settings (jupyterlab#4) * Add a menu option to open the AI settings * Remove the input option from the setting widget * pre-commit * linting * Homogeneize typing for optional arguments * Fix import * Showing that the bot is writing (answering) (jupyterlab#5) * Show that the bot is writing (answering) * Update jupyter chat dependency * Some typing * Update extension to jupyterlab_chat (0.6.0) (jupyterlab#8) * Fix linting * Remove try/except to import jupyterlab_chat (not optional anymore), and fix typing * linter * Python unit tests * Fix typing * lint * Fix lint and mypy all together * Fix web_app settings accessor * Fix jupyter_collaboration version Co-authored-by: david qiu <44106031+dlqqq@users.noreply.github.com> * Remove unecessary try/except * Dedicate one set of chat handlers per room (jupyterlab#9) * create new set of chat handlers per room * make YChat an instance attribute on BaseChatHandler * revert changes to chat handlers * pre-commit * use room_id local var Co-authored-by: Nicolas Brichet <32258950+brichet@users.noreply.github.com> --------- Co-authored-by: Nicolas Brichet <32258950+brichet@users.noreply.github.com> --------- Co-authored-by: david qiu <44106031+dlqqq@users.noreply.github.com> Co-authored-by: david qiu <david@qiu.dev> * Backport PR jupyterlab#1134: Improve user messaging and documentation for Cross-Region Inference on Amazon Bedrock (jupyterlab#1143) Co-authored-by: Sanjiv Das <srdas@scu.edu> * Backport PR jupyterlab#1136: Add base API URL field for Ollama and OpenAI embedding models (jupyterlab#1149) Co-authored-by: Sanjiv Das <srdas@scu.edu> * [v3-dev] Remove `/export`, `/clear`, and `/fix` (jupyterlab#1148) * remove /export * remove /clear * remove /fix * Fix CI in `v3-dev` branch (jupyterlab#1154) * 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> * [v3-dev] Dedicate one LangChain history object per chat (jupyterlab#1151) * dedicate a separate LangChain history object per chat * pre-commit * fix mypy * Backport PR jupyterlab#1160: Trigger update snapshots based on commenter's role (jupyterlab#1161) Co-authored-by: david qiu <david@qiu.dev> * Backport PR jupyterlab#1155: Fix code output format in IPython (jupyterlab#1162) Co-authored-by: Divyansh Choudhary <divyanshchoudhary99@gmail.com> * Backport PR jupyterlab#1158: Update `/generate` to not split classes & functions across cells (jupyterlab#1164) Co-authored-by: Sanjiv Das <srdas@scu.edu> * Remove v2 frontend components (jupyterlab#1156) * First pass to remove the front end chat * Remove code-toolbar by using a simplified markdown renderer in settings * Remove chat-message-menu (should be ported in jupyter-chat) * Remove chat handler * Follow up 'Remove chat-message-menu (should be ported in jupyter-chat)' commit * Clean package.json * Remove UI tests * Remove the generative AI menu * Remove unused components * run yarn dedupe --------- Co-authored-by: David L. Qiu <david@qiu.dev> * Upgrade to `jupyterlab-chat>=0.7.0` (jupyterlab#1166) * upgrade to jupyterlab-chat 0.7.0 * pre-commit * upgrade to @jupyter/chat ^0.7.0 in frontend * Remove v2 backend components (jupyterlab#1168) * remove v2 llm memory, implement ReplyStream * remove v2 websockets & REST handlers * remove unused v2 data models * fix slash command autocomplete * fix unit tests * remove unused _learned context provider * fix mypy * pre-commit * fix optional k arg in YChatHistory * bump jupyter chat to 0.7.1 to fix Python 3.9 tests * revert accidentally breaking /learn --------- Co-authored-by: Lumberbot (aka Jack) <39504233+meeseeksmachine@users.noreply.github.com> Co-authored-by: Sanjiv Das <srdas@scu.edu> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Alan Meeson <alanmeeson@users.noreply.github.com> Co-authored-by: Mahmut CAVDAR <4072246+mcavdar@users.noreply.github.com> Co-authored-by: ctcjab <joshua.bronson@chicagotrading.com> Co-authored-by: Mr.W <janus.choy@gmail.com> Co-authored-by: Nicolas Brichet <32258950+brichet@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Divyansh Choudhary <divyanshchoudhary99@gmail.com>
Related to #785 and #862
This PR make use of the collaborative chat in place of the chat integrated in jupyter-ai.
In this first step, both chats co-exist (to be able to compare the features), that's why we can see 2 left panel icons, one for the collaborative chat sidebar and one for the
jupyter-ai
chat.Currently, the
Jupyternaut
personna is connected every chat, and answers to every message in the chat.Work in progress
Jupyternaut
from a chat