diff --git a/src/lib/ChatCompletionResponse.svelte b/src/lib/ChatCompletionResponse.svelte index ab5fcff..72fd4e0 100644 --- a/src/lib/ChatCompletionResponse.svelte +++ b/src/lib/ChatCompletionResponse.svelte @@ -175,15 +175,15 @@ export class ChatCompletionResponse { } as Message) } this.notifyMessageChange() - setTimeout(() => this.finish(), 250) // give others a chance to signal the finish first + setTimeout(() => this.finish(), 200) // give others a chance to signal the finish first } updateFromClose (force: boolean = false): void { if (!this.finished && !this.error && !this.messages?.find(m => m.content)) { - if (!force) return setTimeout(() => this.updateFromClose(true), 250) as any - return this.updateFromError('Unexpected connection termination') + if (!force) return setTimeout(() => this.updateFromClose(true), 300) as any + if (!this.finished) return this.updateFromError('Unexpected connection termination') } - setTimeout(() => this.finish(), 250) // give others a chance to signal the finish first + setTimeout(() => this.finish(), 260) // give others a chance to signal the finish first } onMessageChange = (listener: (m: Message[]) => void): number => diff --git a/src/lib/ChatRequestPetals.svelte b/src/lib/ChatRequestPetals.svelte index eefd31d..356ae12 100644 --- a/src/lib/ChatRequestPetals.svelte +++ b/src/lib/ChatRequestPetals.svelte @@ -49,6 +49,7 @@ export const runPetalsCompletionRequest = async ( const response = JSON.parse(event.data) if (!response.ok) { const err = new Error('Error opening socket: ' + response.traceback) + chatResponse.updateFromError(err.message) console.error(err) throw err } @@ -89,6 +90,7 @@ export const runPetalsCompletionRequest = async ( if (!response.ok) { const err = new Error('Error in response: ' + response.traceback) console.error(err) + chatResponse.updateFromError(err.message) throw err } window.setTimeout(() => {