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

support autocomplete with Deep Learning #1457

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,17 @@ To disable the extension again, use

jupyter nbextension disable <nbextension require path>

**Notice**, if you are using the notebook extension which need request the server extension.
You need to enable the server extension before starting the jupyter notebook.
This operation only needs to be done once. Currently, there is only one notebook extension
needs the server extension. That is `jupyter_tabnine`. To enable it's server extension, use

jupyter serverextension enable --py jupyter_tabnine

To disable it's server extension again, use

jupyter serverextension disable --py jupyter_tabnine

**Alternatively**, and more conveniently, you can use the
[jupyter_nbextensions_configurator](https://github.com/Jupyter-contrib/jupyter_nbextensions_configurator)
server extension, which is installed as a dependency of this repo, and can be
Expand Down
20 changes: 19 additions & 1 deletion src/jupyter_contrib_nbextensions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
import os

import jupyter_nbextensions_configurator
from notebook.utils import url_path_join as ujoin
from jupyter_tabnine.handler import TabNineHandler
from jupyter_tabnine.tabnine import TabNine

__version__ = '0.5.1'


def _jupyter_server_extension_paths():
"""Magically-named function for jupyter extension installations."""
return []
return [{
'module': 'jupyter_tabnine',
}]


def _jupyter_nbextension_paths():
Expand All @@ -32,3 +37,16 @@ def _jupyter_nbextension_paths():
# _also_ in the `nbextension/` namespace
require=nbext['require'],
) for nbext in specs]


def load_jupyter_server_extension(nb_server_app):
"""
Called when the extension is loaded.
Args:
nb_server_app (NotebookWebApplication): handle to the Notebook webserver instance.
"""
web_app = nb_server_app.web_app
host_pattern = '.*$'
route_pattern = ujoin(web_app.settings['base_url'], '/tabnine')
tabnine = TabNine()
web_app.add_handlers(host_pattern, [(route_pattern, TabNineHandler, {'tabnine': tabnine})])
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Jupyter TabNine
==========
This extension provides code auto-completion based on deep learning.

* Author: Wenmin Wu
* Repository: https://github.com/wenmin-wu/jupyter-tabnine
* Email: [email protected]

Options
-------

* `jupyter_tabnine.before_line_limit`:
maximum number of lines before for context generation,
too many lines will slow down the request. -1 means Infinity,
thus the lines will equal to number of lines before current line.

* `jupyter_tabnine.after_line_limit`:
maximum number of lines after for context generation,
too many lines will slow down the request. -1 means Infinity,
thus the lines will equal to number of lines after current line.

* `jupyter_tabnine.options_limit`:
maximum number of options that will be shown

* `jupyter_tabnine.assist_active`:
Enable continuous code auto-completion when notebook is first opened, or
if false, only when selected from extensions menu.

* `jupytertabnine.assist_delay`:
delay in milliseconds between keypress & completion request.

* `jupyter_tabnine.remote_server_url`:
remote server url, you may want to use a remote server to handle client request.
This can spped up the request handling depending on the server configuration. Refer to [repo doc](https://github.com/wenmin-wu/jupyter-tabnine) to see how to deploy remote server.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
.complete-container {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
vertical-align: middle;
font-family: monospace, monospace;
}

.complete-block {
min-width: 200px;
margin: 2px;
padding: 1px;
display: inline-block;
}

.user-message {
margin: 2px;
padding: 1px;
display: list-item;
}

.user-message span {
color: #CD5C5C;
}



.complete-word {
width: auto;
text-align: left;
}

.complete-detail {
text-align: right;
}


.complete-dropdown-content {
background-color: rgb(255, 255, 255, 0.85);
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.5);
}
Loading