Better error handling for Petals

This commit is contained in:
Webifi 2023-07-22 17:08:40 -05:00
parent 15dcd27e8f
commit 7aadca3c5c
2 changed files with 6 additions and 4 deletions

View File

@ -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 =>

View File

@ -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(() => {