forked from open-webui/open-webui
		
	feat: error handling for when ollama is not running
This commit is contained in:
		
							parent
							
								
									93cffa89f6
								
							
						
					
					
						commit
						5262156c24
					
				
					 2 changed files with 32 additions and 18 deletions
				
			
		|  | @ -189,17 +189,12 @@ | ||||||
| 				}, | 				}, | ||||||
| 				format: $settings.requestFormat ?? undefined | 				format: $settings.requestFormat ?? undefined | ||||||
| 			}) | 			}) | ||||||
|  | 		}).catch((err) => { | ||||||
|  | 			console.log(err); | ||||||
|  | 			return null; | ||||||
| 		}); | 		}); | ||||||
| 
 | 
 | ||||||
| 		if (!res.ok) { | 		if (res && res.ok) { | ||||||
| 			const error = await res.json(); |  | ||||||
| 			console.log(error); |  | ||||||
| 			if ('detail' in error) { |  | ||||||
| 				toast.error(error.detail); |  | ||||||
| 			} else { |  | ||||||
| 				toast.error(error.error); |  | ||||||
| 			} |  | ||||||
| 		} else { |  | ||||||
| 			const reader = res.body | 			const reader = res.body | ||||||
| 				.pipeThrough(new TextDecoderStream()) | 				.pipeThrough(new TextDecoderStream()) | ||||||
| 				.pipeThrough(splitStream('\n')) | 				.pipeThrough(splitStream('\n')) | ||||||
|  | @ -275,6 +270,18 @@ | ||||||
| 					history: history | 					history: history | ||||||
| 				}); | 				}); | ||||||
| 			} | 			} | ||||||
|  | 		} else { | ||||||
|  | 			if (res !== null) { | ||||||
|  | 				const error = await res.json(); | ||||||
|  | 				console.log(error); | ||||||
|  | 				if ('detail' in error) { | ||||||
|  | 					toast.error(error.detail); | ||||||
|  | 				} else { | ||||||
|  | 					toast.error(error.error); | ||||||
|  | 				} | ||||||
|  | 			} else { | ||||||
|  | 				toast.error(`Uh-oh! There was an issue connecting to Ollama.`); | ||||||
|  | 			} | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		stopResponseFlag = false; | 		stopResponseFlag = false; | ||||||
|  |  | ||||||
|  | @ -216,17 +216,12 @@ | ||||||
| 				}, | 				}, | ||||||
| 				format: $settings.requestFormat ?? undefined | 				format: $settings.requestFormat ?? undefined | ||||||
| 			}) | 			}) | ||||||
|  | 		}).catch((err) => { | ||||||
|  | 			console.log(err); | ||||||
|  | 			return null; | ||||||
| 		}); | 		}); | ||||||
| 
 | 
 | ||||||
| 		if (!res.ok) { | 		if (res && res.ok) { | ||||||
| 			const error = await res.json(); |  | ||||||
| 			console.log(error); |  | ||||||
| 			if ('detail' in error) { |  | ||||||
| 				toast.error(error.detail); |  | ||||||
| 			} else { |  | ||||||
| 				toast.error(error.error); |  | ||||||
| 			} |  | ||||||
| 		} else { |  | ||||||
| 			const reader = res.body | 			const reader = res.body | ||||||
| 				.pipeThrough(new TextDecoderStream()) | 				.pipeThrough(new TextDecoderStream()) | ||||||
| 				.pipeThrough(splitStream('\n')) | 				.pipeThrough(splitStream('\n')) | ||||||
|  | @ -302,6 +297,18 @@ | ||||||
| 					history: history | 					history: history | ||||||
| 				}); | 				}); | ||||||
| 			} | 			} | ||||||
|  | 		} else { | ||||||
|  | 			if (res !== null) { | ||||||
|  | 				const error = await res.json(); | ||||||
|  | 				console.log(error); | ||||||
|  | 				if ('detail' in error) { | ||||||
|  | 					toast.error(error.detail); | ||||||
|  | 				} else { | ||||||
|  | 					toast.error(error.error); | ||||||
|  | 				} | ||||||
|  | 			} else { | ||||||
|  | 				toast.error(`Uh-oh! There was an issue connecting to Ollama.`); | ||||||
|  | 			} | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		stopResponseFlag = false; | 		stopResponseFlag = false; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Timothy J. Baek
						Timothy J. Baek