diff --git a/package-lock.json b/package-lock.json index 6f63e20c..49ce875b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4798,9 +4798,9 @@ } }, "node_modules/vite": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/vite/-/vite-4.5.2.tgz", - "integrity": "sha512-tBCZBNSBbHQkaGyhGCDUGqeo2ph8Fstyp6FMSvTtsXeZSPpSMGlviAOav2hxVTqFcx8Hj/twtWKsMJXNY0xI8w==", + "version": "4.5.3", + "resolved": "https://registry.npmjs.org/vite/-/vite-4.5.3.tgz", + "integrity": "sha512-kQL23kMeX92v3ph7IauVkXkikdDRsYMGTVl5KY2E9OY4ONLvkHf04MDTbnfo6NKxZiDLWzVpP5oTa8hQD8U3dg==", "dev": true, "dependencies": { "esbuild": "^0.18.10", diff --git a/src/lib/ChatRequest.svelte b/src/lib/ChatRequest.svelte index 6c91d42f..e25f9bb1 100644 --- a/src/lib/ChatRequest.svelte +++ b/src/lib/ChatRequest.svelte @@ -36,23 +36,23 @@ export class ChatRequest { return this.chat.settings } - // Common error handler + // Common error handler with response OK check async handleError (response) { - let errorResponse + if (response.ok) return; + let errorResponse; try { - const errObj = await response.json() - errorResponse = errObj?.error?.message || errObj?.error?.code + const errObj = await response.json(); + errorResponse = errObj?.error?.message || errObj?.error?.code; if (!errorResponse && response.choices && response.choices[0]) { - errorResponse = response.choices[0]?.message?.content + errorResponse = response.choices[0]?.message?.content; } - errorResponse = errorResponse || 'Unexpected Response' + errorResponse = errorResponse || 'Unexpected Response'; } catch (e) { - console.error(e, e.stack) - errorResponse = 'Unknown Response' + console.error(e, e.stack); + errorResponse = 'Unknown Response'; } - throw new Error(`${response.status} - ${errorResponse}`) + throw new Error(`${response.status} - ${errorResponse}`); } - /** * Send API request * @param messages diff --git a/src/lib/providers/openai/models.svelte b/src/lib/providers/openai/models.svelte index 837269e9..b2352fbb 100644 --- a/src/lib/providers/openai/models.svelte +++ b/src/lib/providers/openai/models.svelte @@ -96,6 +96,7 @@ export const chatModels : Record = { 'gpt-3.5-turbo-16k': { ...gpt3516k }, 'gpt-3.5-turbo-16k-0613': { ...gpt3516k }, 'gpt-4': { ...gpt4 }, + 'gpt-4-turbo': { ...gpt4128kpreview }, 'gpt-4-turbo-preview': { ...gpt4128kpreview }, 'gpt-4-0314': { ...gpt4 }, 'gpt-4-0613': { ...gpt4 },