forked from open-webui/open-webui
		
	fix: text completion replaced with chat completion
This commit is contained in:
		
							parent
							
								
									2379e94cbf
								
							
						
					
					
						commit
						06ce5aed4a
					
				
					 1 changed files with 11 additions and 3 deletions
				
			
		|  | @ -8,7 +8,7 @@ | |||
| 	import { WEBUI_API_BASE_URL } from '$lib/constants'; | ||||
| 	import { WEBUI_NAME, config, user, models } from '$lib/stores'; | ||||
| 
 | ||||
| 	import { cancelChatCompletion, generateTextCompletion } from '$lib/apis/ollama'; | ||||
| 	import { cancelChatCompletion, generateChatCompletion } from '$lib/apis/ollama'; | ||||
| 	import { splitStream } from '$lib/utils'; | ||||
| 
 | ||||
| 	let mode = 'complete'; | ||||
|  | @ -44,7 +44,15 @@ | |||
| 		if (selectedModel) { | ||||
| 			loading = true; | ||||
| 
 | ||||
| 			const res = await generateTextCompletion(localStorage.token, selectedModel, text); | ||||
| 			const [res, controller] = await generateChatCompletion(localStorage.token, { | ||||
| 				model: selectedModel, | ||||
| 				messages: [ | ||||
| 					{ | ||||
| 						role: 'assistant', | ||||
| 						content: text | ||||
| 					} | ||||
| 				] | ||||
| 			}); | ||||
| 
 | ||||
| 			if (res && res.ok) { | ||||
| 				const reader = res.body | ||||
|  | @ -80,7 +88,7 @@ | |||
| 									currentRequestId = data.id; | ||||
| 								} else { | ||||
| 									if (data.done == false) { | ||||
| 										text += data.response; | ||||
| 										text += data.message.content; | ||||
| 									} else { | ||||
| 										console.log('done'); | ||||
| 									} | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Timothy J. Baek
						Timothy J. Baek