Skip to content

Commit

Permalink
Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
krassowski committed Oct 4, 2023
1 parent aa82ca0 commit fa3dfed
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ interface ISettings {

const DEFAULT_SETTINGS: ISettings = {
codeModel: 'Xenova/tiny_starcoder_py',
textModel: 'Xenova/tiny_starcoder_py',
textModel: 'Xenova/gpt2',
temperature: 0.5,
doSample: false,
topK: 5,
Expand Down Expand Up @@ -141,6 +141,8 @@ class TransformersInlineProvider implements IInlineCompletionProvider {
description:
'Time since the last key press to start generation (debouncer) in milliseconds.'
},
// TODO: characters are a poor proxy for number of tokens when whitespace are many (though a strictly conservative one).
// Words could be better but can be over-optimistic - one word canb e several tokens).
maxContextWindow: {
title: 'Maximum context window',
minimum: 1,
Expand All @@ -155,7 +157,6 @@ class TransformersInlineProvider implements IInlineCompletionProvider {

configure(settings: { [property: string]: JSONValue }): void {
this._settings = settings as any as ISettings;
console.log(this._settings);
this._debouncer = new Debouncer(
this._fetch.bind(this),
this._settings.debounceMilliseconds ??
Expand Down Expand Up @@ -188,7 +189,6 @@ class TransformersInlineProvider implements IInlineCompletionProvider {

// TODO types
onMessageReceived(e: any) {
console.log(e);
const data = e.data;
// TODO: maybe only tick on update?
this._tickWorker();
Expand Down Expand Up @@ -287,7 +287,6 @@ class TransformersInlineProvider implements IInlineCompletionProvider {
});
}
this._streamPromises.delete(token);
console.log('exception');
break;
}
}
Expand Down Expand Up @@ -325,7 +324,6 @@ class TransformersInlineProvider implements IInlineCompletionProvider {
const prefix = textBefore.slice(
-Math.min(this._settings.maxContextWindow, textBefore.length)
);
console.log(prefix);
return prefix;
}

Expand All @@ -336,9 +334,11 @@ class TransformersInlineProvider implements IInlineCompletionProvider {
await this._ready.promise;
this._abortPrevious();
this._streamPromises = new Map();
console.log(request.mimeType);
const textMimeTypes = ['text/markdown', 'text/plain'];
const model = textMimeTypes.includes(request.mimeType)

const textMimeTypes = ['text/x-markdown', 'text/plain'];
const isText = textMimeTypes.includes(request.mimeType);
// TODO add a setting to only invoke on text if explicitly asked (triggerKind = invoke)
const model = isText
? this._settings.textModel
: this._settings.codeModel;

Expand Down

0 comments on commit fa3dfed

Please sign in to comment.