diff --git a/packages/backend/src/managers/playgroundV2Manager.spec.ts b/packages/backend/src/managers/playgroundV2Manager.spec.ts index c59b71e95..b38a50fe6 100644 --- a/packages/backend/src/managers/playgroundV2Manager.spec.ts +++ b/packages/backend/src/managers/playgroundV2Manager.spec.ts @@ -182,7 +182,7 @@ test('valid submit should create IPlaygroundMessage and notify the webview', asy id: expect.anything(), options: undefined, role: 'user', - timestamp: date.getTime(), + timestamp: expect.any(Number), }); expect(conversations[0].messages[1]).toStrictEqual({ choices: undefined, @@ -190,7 +190,7 @@ test('valid submit should create IPlaygroundMessage and notify the webview', asy content: '', id: expect.anything(), role: 'assistant', - timestamp: date.getTime(), + timestamp: expect.any(Number), }); expect(webviewMock.postMessage).toHaveBeenLastCalledWith({ diff --git a/packages/backend/src/managers/playgroundV2Manager.ts b/packages/backend/src/managers/playgroundV2Manager.ts index c43ed32c9..903927033 100644 --- a/packages/backend/src/managers/playgroundV2Manager.ts +++ b/packages/backend/src/managers/playgroundV2Manager.ts @@ -126,16 +126,22 @@ export class PlaygroundV2Manager extends Publisher implements Di if (systemPrompt) { messages.push({ role: 'system', content: systemPrompt }); } - const response = await client.chat.completions.create({ - messages, - stream: true, - model: modelInfo.file.file, - ...options, - }); - // process stream async - this.processStream(playground.id, response).catch((err: unknown) => { - console.error('Something went wrong while processing stream', err); - }); + client.chat.completions + .create({ + messages, + stream: true, + model: modelInfo.file.file, + ...options, + }) + .then(response => { + // process stream async + this.processStream(playground.id, response).catch((err: unknown) => { + console.error('Something went wrong while processing stream', err); + }); + }) + .catch((err: unknown) => { + console.error('Something went wrong while creating model reponse', err); + }); } /**