-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Experimental inline completer #15160
Experimental inline completer #15160
Conversation
Thanks for making a pull request to jupyterlab! |
What about https://pictogrammers.com/library/mdi/icon/history/ |
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.
Thanks @krassowski
Here are my questions/suggestions on the API.
@@ -138,6 +138,131 @@ export interface ICompletionProvider< | |||
): boolean; | |||
} | |||
|
|||
/** | |||
* Describes how an inline completion provider was triggered. | |||
* @alpha |
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.
should we use @Alpha or @experimental to align with the new API ts doc?
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.
I wanted to ask about this. Do you have a link explaining differences? From the docs it seems that @experimental
== @beta
. I see that in injectExtension
we have both:
jupyterlab/packages/codemirror/src/editor.ts
Lines 226 to 227 in e00fdc4
* @alpha | |
* @experimental |
I don't know which one we should prefer.
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.
If I recall correctly, this is exactly what is mentioned in tsdoc:
Same semantics as @\beta, but used by tools that don't support an @\alpha release stage.
Some tools have experimental and not alpha/beta, other the other way around (like API extractor). I think experimental was even the only one supported by tsdoc in the past.
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.
Would you prefer me to change the existing tag comments to:
* @alpha
* @experimental
or are they good as they are?
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.
Let's keep it like this as alpha
/ beta
is clearer than experimental
in term of API stability expectation.
Co-authored-by: Frédéric Collonval <fcollonval@users.noreply.github.com>
This is based on the observation that various providers have different ways of styling the ghost text, for example by adding brand-specific background; to enable providers to style the ghost text specifically this commit adds a data attribute on the ghost text widget.
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.
Thank you for taking a look @fcollonval, hugely appreciated!
@@ -138,6 +138,131 @@ export interface ICompletionProvider< | |||
): boolean; | |||
} | |||
|
|||
/** | |||
* Describes how an inline completion provider was triggered. | |||
* @alpha |
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.
I wanted to ask about this. Do you have a link explaining differences? From the docs it seems that @experimental
== @beta
. I see that in injectExtension
we have both:
jupyterlab/packages/codemirror/src/editor.ts
Lines 226 to 227 in e00fdc4
* @alpha | |
* @experimental |
I don't know which one we should prefer.
@@ -197,6 +223,46 @@ export class CompletionProviderManager implements ICompletionProviderManager { | |||
} | |||
} | |||
|
|||
/** |
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.
Good point, there is a place in the IModel
where it seems more relevant (but then it is further away from the extension point). I do not see it for cycleInline
specifically, can you elaborate? The future possibilities for extension that I see could be direction: 'first' | 'last'
.
bot please update galata snapshots |
Galata snapshots updated. |
0c2c0b0
to
7a7151e
Compare
Hello @krassowski In this case, I don't get additional information like type of documentation from the inline completer like I do from the completer widget, is this intended behavior? |
Hello @dongs0104 👋
Yes, this is documented, quoting from
We could add additional information about the inline completion in the future (e.g. allow models to generate both text and a plain-text comment) but "type" really does not make sense when returning multiple lines of code, for example if type import pandas
x = pandas.DataFrame()
y = 1
print(x, y) There is no single type here. Similarly for documentation.
Yes, you can get the content of editor/notebook from context. Extracting a single line is presented the History provider, while the reference implementation in https://github.com/krassowski/jupyterlab-transformers-completer demonstrates using more lines (with a cap at the context length because this has an impact on generation speed). |
If there are no further comments, it would be helpful to merge and cut a pre-release to allow wider testing (setting up a binder with krassowski/jupyterlab-transformers-completer is proving to be difficult due to Binder runners restrictions). |
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.
Hey @krassowski
I only have one comment about the icon for the settings. It seems they are not using jp-icon
classes and therefore may not be styled properly depending on the theme. For example in dark mode:
@@ -197,6 +223,46 @@ export class CompletionProviderManager implements ICompletionProviderManager { | |||
} | |||
} | |||
|
|||
/** |
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.
I was not seeing a specific case for cycleInline
. It was more to be sure to think a second times about that; as you did 😉
@@ -138,6 +138,131 @@ export interface ICompletionProvider< | |||
): boolean; | |||
} | |||
|
|||
/** | |||
* Describes how an inline completion provider was triggered. | |||
* @alpha |
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.
Let's keep it like this as alpha
/ beta
is clearer than experimental
in term of API stability expectation.
Co-authored-by: Frédéric Collonval <fcollonval@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.
Thanks @krassowski
References
Relates to #14267
Reference implementation: krassowski/jupyterlab-transformers-completer
Code changes
IInlineCompletionProvider
for extensions to provide inline completions (for example from various LLMs)ICompletionManager
API with new methods:.registerInlineProvider(provider: IInlineCompletionProvider)
inline
actions namespace:.inline.invoke(id: string)
.inline.cycle(id: string, direction: 'next' | 'previous')
.inline.accept(id: string)
.inline.configure(settings)
Provider API overview
IInlineCompletionItem
InlineCompletionTriggerKind
IInlineCompletionContext
CompletionHandler.IRequest
Note: this differs from context in that the request can change within editor depending on editor state (content, cursor position), while context (except for
triggerKind
) is largely stable.mimeType
can change when transclusions are present, for example JavaScript within<script></script>
tag. For markdown cells a markdown mime type is returned.Advantages:
IInlineCompletionItem
andInlineCompletionTriggerKind
is a super-set of proposed Language Server Protocol v3.18 API for inline completions which will enable connecting LSP servers as a source of inline completions in the futuremimeType
of requestInline Completer
tab of settings rather than having the settings scattered around (as it is currently a problem and confusion for LSP users because the Tab Completer does not offer such API)Limitations:
isIncomplete: bool
onIInlineCompletionList
and a new trigger kindTriggerForIncompleteCompletions
onInlineCompletionTriggerKind
; then when provider'sfetch()
method would be called for the second time with this trigger kind if the list was incomplete and provider would return additionalitems
.token
onIInlineCompletionList
result and a new methodstreamList(token)
method onIInlineCompletionProvider
(but by virtue of sticking with LSP land I think the above is better; we could even propose it upstream)User-facing changes
The last icon represents provider (source) of the completions (here history) and is cusomizable by providers.
Note: the intention is to allow accepting the suggestion with Tab but this will likely follow in a separate pull request once #14115 is merged.
New settings section
(plus Code Completer got an icon ✨)
Backwards-incompatible changes
To check.
To be done