Skip to content

Commit

Permalink
abbreviate JupyterAIInlineProvider => JaiInlineProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
dlqqq committed Jan 16, 2024
1 parent 3948cae commit ff197cf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
10 changes: 5 additions & 5 deletions packages/jupyter-ai/src/completions/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from '@jupyterlab/codemirror';
import { getEditor } from '../selection-watcher';
import { IJaiStatusItem } from '../tokens';
import { displayName, JupyterAIInlineProvider } from './provider';
import { displayName, JaiInlineProvider } from './provider';
import { CompletionWebsocketHandler } from './handler';

export namespace CommandIDs {
Expand Down Expand Up @@ -52,7 +52,7 @@ export const completionPlugin: JupyterFrontEndPlugin<void> = {
return;
}
const completionHandler = new CompletionWebsocketHandler();
const provider = new JupyterAIInlineProvider({
const provider = new JaiInlineProvider({
completionHandler,
languageRegistry
});
Expand Down Expand Up @@ -84,7 +84,7 @@ export const completionPlugin: JupyterFrontEndPlugin<void> = {
}
const providers = Object.assign({}, settings.user.providers) as any;
const ourSettings = {
...JupyterAIInlineProvider.DEFAULT_SETTINGS,
...JaiInlineProvider.DEFAULT_SETTINGS,
...providers[provider.identifier]
};
const wasEnabled = ourSettings['enabled'];
Expand All @@ -104,8 +104,8 @@ export const completionPlugin: JupyterFrontEndPlugin<void> = {
return;
}
const providers = Object.assign({}, settings.user.providers) as any;
const ourSettings: JupyterAIInlineProvider.ISettings = {
...JupyterAIInlineProvider.DEFAULT_SETTINGS,
const ourSettings: JaiInlineProvider.ISettings = {
...JaiInlineProvider.DEFAULT_SETTINGS,
...providers[provider.identifier]
};
const wasDisabled = ourSettings['disabledLanguages'].includes(
Expand Down
18 changes: 10 additions & 8 deletions packages/jupyter-ai/src/completions/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ export function displayName(language: IEditorLanguage): string {
return language.displayName ?? language.name;
}

export class JupyterAIInlineProvider implements IInlineCompletionProvider {
readonly identifier = 'jupyter-ai';
export class JaiInlineProvider implements IInlineCompletionProvider {
readonly identifier = '@jupyterlab/jupyter-ai';
readonly icon = jupyternautIcon.bindprops({ width: 16, top: 1 });

constructor(protected options: JupyterAIInlineProvider.IOptions) {
constructor(protected options: JaiInlineProvider.IOptions) {
options.completionHandler.streamed.connect(this._receiveStreamChunk, this);
}

Expand Down Expand Up @@ -175,12 +175,12 @@ export class JupyterAIInlineProvider implements IInlineCompletionProvider {
description: 'Whether to show suggestions as they are generated'
}
},
default: JupyterAIInlineProvider.DEFAULT_SETTINGS as any
default: JaiInlineProvider.DEFAULT_SETTINGS as any
};
}

async configure(settings: { [property: string]: JSONValue }): Promise<void> {
this._settings = settings as unknown as JupyterAIInlineProvider.ISettings;
this._settings = settings as unknown as JaiInlineProvider.ISettings;
}

isEnabled(): boolean {
Expand Down Expand Up @@ -248,19 +248,20 @@ export class JupyterAIInlineProvider implements IInlineCompletionProvider {
return language.name;
}

private _settings: JupyterAIInlineProvider.ISettings =
JupyterAIInlineProvider.DEFAULT_SETTINGS;
private _settings: JaiInlineProvider.ISettings =
JaiInlineProvider.DEFAULT_SETTINGS;

private _streamPromises: Map<string, PromiseDelegate<StreamChunk>> =
new Map();
private _counter = 0;
}

export namespace JupyterAIInlineProvider {
export namespace JaiInlineProvider {
export interface IOptions {
completionHandler: CompletionWebsocketHandler;
languageRegistry: IEditorLanguageRegistry;
}

export interface ISettings {
maxPrefix: number;
maxSuffix: number;
Expand All @@ -269,6 +270,7 @@ export namespace JupyterAIInlineProvider {
disabledLanguages: string[];
streaming: 'always' | 'manual' | 'never';
}

export const DEFAULT_SETTINGS: ISettings = {
maxPrefix: 10000,
maxSuffix: 10000,
Expand Down

0 comments on commit ff197cf

Please sign in to comment.