Better error handling for Petals
This commit is contained in:
parent
15dcd27e8f
commit
7aadca3c5c
|
@ -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 =>
|
||||
|
|
|
@ -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(() => {
|
||||
|
|
Loading…
Reference in New Issue