Better error handling for Petals
This commit is contained in:
		
							parent
							
								
									15dcd27e8f
								
							
						
					
					
						commit
						7aadca3c5c
					
				|  | @ -175,15 +175,15 @@ export class ChatCompletionResponse { | ||||||
|       } as Message) |       } as Message) | ||||||
|     } |     } | ||||||
|     this.notifyMessageChange() |     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 { |   updateFromClose (force: boolean = false): void { | ||||||
|     if (!this.finished && !this.error && !this.messages?.find(m => m.content)) { |     if (!this.finished && !this.error && !this.messages?.find(m => m.content)) { | ||||||
|       if (!force) return setTimeout(() => this.updateFromClose(true), 250) as any |       if (!force) return setTimeout(() => this.updateFromClose(true), 300) as any | ||||||
|       return this.updateFromError('Unexpected connection termination') |       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 => |   onMessageChange = (listener: (m: Message[]) => void): number => | ||||||
|  |  | ||||||
|  | @ -49,6 +49,7 @@ export const runPetalsCompletionRequest = async ( | ||||||
|           const response = JSON.parse(event.data) |           const response = JSON.parse(event.data) | ||||||
|           if (!response.ok) { |           if (!response.ok) { | ||||||
|             const err = new Error('Error opening socket: ' + response.traceback) |             const err = new Error('Error opening socket: ' + response.traceback) | ||||||
|  |             chatResponse.updateFromError(err.message) | ||||||
|             console.error(err) |             console.error(err) | ||||||
|             throw err |             throw err | ||||||
|           } |           } | ||||||
|  | @ -89,6 +90,7 @@ export const runPetalsCompletionRequest = async ( | ||||||
|             if (!response.ok) { |             if (!response.ok) { | ||||||
|               const err = new Error('Error in response: ' + response.traceback) |               const err = new Error('Error in response: ' + response.traceback) | ||||||
|               console.error(err) |               console.error(err) | ||||||
|  |               chatResponse.updateFromError(err.message) | ||||||
|               throw err |               throw err | ||||||
|             } |             } | ||||||
|             window.setTimeout(() => { |             window.setTimeout(() => { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Webifi
						Webifi