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

Added doc indexing, moved processing to ray actors #67

Merged
merged 6 commits into from
Apr 15, 2023

Conversation

3coins
Copy link
Collaborator

@3coins 3coins commented Apr 15, 2023

Summary

This PR moves the chat prediction code to distributed tasks using ray actors, this will allow non-blocking processing of chat requests. To process the replies, a ReplyProcessor has been added that that will distribute the replies from the chat provider. This PR also includes the ability to load the specified directories into a FAISS index, which can be used to ask questions pertaining to the loaded documents. Users can type /index <dir-name> in the chat to start loading the directories. They can then use the /fs <question> or /filesystem <question> to ask a question, which will switch to a RAG chain to get relevant context from the indexed documents.

Demo

chat-index-docs-1

Tasks

  • Moved chat provider prediction to ray actors, allows non-blocking distributed tasks
  • Added a reply processor, single processor to distribute replies from actors, this was originally in the web socket
  • Ability to index directories, users can index directories from chat by sending /read <dir-name>
  • Ability to chat with indexed directories, users can chat with indexed directories by sending /fs <query>
  • Save index to file, so users can ask questions about directories indexed in previous sessions
  • Add a menu item for indexing directories from the file browser
  • Add a data loader for faster directory indexing, explore dask or ray for this
  • Add loading for python, markdown and R files
  • Add sources in the reply
  • Some visual indication of what directories are indexed
  • Mechanism to reply to user if directory is already indexed, and take input from user if they want to update the index

@3coins 3coins self-assigned this Apr 15, 2023
@3coins 3coins added the enhancement New feature or request label Apr 15, 2023
@3coins 3coins requested a review from ellisonbg April 15, 2023 18:09
Copy link
Contributor

@ellisonbg ellisonbg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really amazing work! I left some specific feedback inline, but overall the design is really solid. It is great to see how we can use ray like this to build a more robust, distributed backend for usage cases like this. Super cool!

packages/jupyter-ai/jupyter_ai/actors.py Outdated Show resolved Hide resolved
packages/jupyter-ai/jupyter_ai/actors.py Outdated Show resolved Hide resolved
packages/jupyter-ai/jupyter_ai/actors.py Show resolved Hide resolved
if(message.body.startswith("/")):
command = message.body.split(' ', 1)[0]
if command in COMMANDS.keys():
actor = ray.get_actor(COMMANDS[command].value)

This comment was marked as resolved.

This comment was marked as resolved.

packages/jupyter-ai/jupyter_ai/actors.py Show resolved Hide resolved

index_actor = ray.get_actor(ACTOR_TYPE.READ.value)
handle = index_actor.get_index.remote()
vectorstore = ray.get(handle)

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as resolved.

packages/jupyter-ai/jupyter_ai/actors.py Outdated Show resolved Hide resolved
packages/jupyter-ai/jupyter_ai/actors.py Outdated Show resolved Hide resolved
packages/jupyter-ai/jupyter_ai/reply_processor.py Outdated Show resolved Hide resolved
@3coins 3coins marked this pull request as ready for review April 15, 2023 22:22
@3coins 3coins merged commit d2ff108 into jupyterlab:main Apr 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants