diff --git a/packages/jupyter-ai/src/bigcode-Inline-completion-provider.ts b/packages/jupyter-ai/src/bigcode-Inline-completion-provider.ts index 2abfbd77f..2beaec470 100644 --- a/packages/jupyter-ai/src/bigcode-Inline-completion-provider.ts +++ b/packages/jupyter-ai/src/bigcode-Inline-completion-provider.ts @@ -295,7 +295,7 @@ export class BigcodeInlineCompletionProvider '"""This is the first line generated by the mockKeypressCompletionStreamr"""\n """This is the second line generated by the mockKeypressCompletionStream"""'; for (let i = 1; i <= testResultText.length; i++) { - await this.delay(25); + await this.delay(10); if (this._streamStop) { console.debug('_streamStop'); @@ -382,8 +382,7 @@ export class BigcodeInlineCompletionProvider const { value, done } = await reader.read(); if (done || this._streamStop) { - this.setRequestFinish(false); - break; + return; } const strValue = decoder.decode(value, { stream: true }); @@ -397,15 +396,13 @@ export class BigcodeInlineCompletionProvider ) as BigCodeServiceStreamResponseItem; const done = chunkData.token.special; - if (done) { - this.setRequestFinish(false); - } else { + if (!done) { this._lastRequestInfo.insertText += chunkData.token.text; } yield { response: { - isIncomplete: !chunkData.token.special, + isIncomplete: !done, insertText: this._lastRequestInfo.insertText } }; @@ -417,14 +414,18 @@ export class BigcodeInlineCompletionProvider async *automaticCompletionStream( token: string ): AsyncGenerator<{ response: IInlineCompletionItem }, undefined, unknown> { - const reponseData = await bigcodeRequestInstance.fetchStream(false); + try { + const reponseData = await bigcodeRequestInstance.fetchStream(false); - yield { - response: { - token, - isIncomplete: false, - insertText: reponseData[0].generated_text - } - }; + yield { + response: { + token, + isIncomplete: false, + insertText: reponseData[0].generated_text + } + }; + } catch { + return; + } } } diff --git a/packages/jupyter-ai/src/utils/bigcode-request.ts b/packages/jupyter-ai/src/utils/bigcode-request.ts index 3be87c08c..3b44d851e 100644 --- a/packages/jupyter-ai/src/utils/bigcode-request.ts +++ b/packages/jupyter-ai/src/utils/bigcode-request.ts @@ -63,7 +63,7 @@ class Bigcode { 'BigCode service URL or Huggingface Access Token not set.' ); } - console.debug(this.prompt); + if (!this._prompt) { throw new Error('Prompt is null'); }