forked from open-webui/open-webui
		
	fix: openai issue
This commit is contained in:
		
							parent
							
								
									f051b366e3
								
							
						
					
					
						commit
						7bc0c09b25
					
				
					 5 changed files with 108 additions and 21 deletions
				
			
		
							
								
								
									
										31
									
								
								src/lib/apis/configs/index.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								src/lib/apis/configs/index.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,31 @@ | |||
| import { WEBUI_API_BASE_URL } from '$lib/constants'; | ||||
| 
 | ||||
| export const setDefaultModels = async (token: string, models: string) => { | ||||
| 	let error = null; | ||||
| 
 | ||||
| 	const res = await fetch(`${WEBUI_API_BASE_URL}/configs/default/models`, { | ||||
| 		method: 'GET', | ||||
| 		headers: { | ||||
| 			'Content-Type': 'application/json', | ||||
| 			Authorization: `Bearer ${token}` | ||||
| 		}, | ||||
| 		body: JSON.stringify({ | ||||
| 			models: models | ||||
| 		}) | ||||
| 	}) | ||||
| 		.then(async (res) => { | ||||
| 			if (!res.ok) throw await res.json(); | ||||
| 			return res.json(); | ||||
| 		}) | ||||
| 		.catch((err) => { | ||||
| 			console.log(err); | ||||
| 			error = err.detail; | ||||
| 			return null; | ||||
| 		}); | ||||
| 
 | ||||
| 	if (error) { | ||||
| 		throw error; | ||||
| 	} | ||||
| 
 | ||||
| 	return res; | ||||
| }; | ||||
|  | @ -6,7 +6,7 @@ | |||
| 	import { goto } from '$app/navigation'; | ||||
| 	import { page } from '$app/stores'; | ||||
| 
 | ||||
| 	import { models, modelfiles, user, settings, chats, chatId } from '$lib/stores'; | ||||
| 	import { models, modelfiles, user, settings, chats, chatId, config } from '$lib/stores'; | ||||
| 	import { OLLAMA_API_BASE_URL } from '$lib/constants'; | ||||
| 
 | ||||
| 	import { generateChatCompletion, generateTitle } from '$lib/apis/ollama'; | ||||
|  | @ -90,9 +90,18 @@ | |||
| 			messages: {}, | ||||
| 			currentId: null | ||||
| 		}; | ||||
| 		selectedModels = $page.url.searchParams.get('models') | ||||
| 			? $page.url.searchParams.get('models')?.split(',') | ||||
| 			: $settings.models ?? ['']; | ||||
| 
 | ||||
| 		console.log($config); | ||||
| 
 | ||||
| 		if ($page.url.searchParams.get('models')) { | ||||
| 			selectedModels = $page.url.searchParams.get('models')?.split(','); | ||||
| 		} else if ($settings?.models) { | ||||
| 			selectedModels = $settings?.models; | ||||
| 		} else if ($config?.default_models) { | ||||
| 			selectedModels = $config?.default_models.split(','); | ||||
| 		} else { | ||||
| 			selectedModels = ['']; | ||||
| 		} | ||||
| 
 | ||||
| 		let _settings = JSON.parse(localStorage.getItem('settings') ?? '{}'); | ||||
| 		settings.set({ | ||||
|  | @ -383,13 +392,13 @@ | |||
| 										  } | ||||
| 										: { content: message.content }) | ||||
| 								})), | ||||
| 							seed: $settings.options.seed ?? undefined, | ||||
| 							stop: $settings.options.stop ?? undefined, | ||||
| 							temperature: $settings.options.temperature ?? undefined, | ||||
| 							top_p: $settings.options.top_p ?? undefined, | ||||
| 							num_ctx: $settings.options.num_ctx ?? undefined, | ||||
| 							frequency_penalty: $settings.options.repeat_penalty ?? undefined, | ||||
| 							max_tokens: $settings.options.num_predict ?? undefined | ||||
| 							seed: $settings?.options?.seed ?? undefined, | ||||
| 							stop: $settings?.options?.stop ?? undefined, | ||||
| 							temperature: $settings?.options?.temperature ?? undefined, | ||||
| 							top_p: $settings?.options?.top_p ?? undefined, | ||||
| 							num_ctx: $settings?.options?.num_ctx ?? undefined, | ||||
| 							frequency_penalty: $settings?.options?.repeat_penalty ?? undefined, | ||||
| 							max_tokens: $settings?.options?.num_predict ?? undefined | ||||
| 						}) | ||||
| 					} | ||||
| 				).catch((err) => { | ||||
|  |  | |||
|  | @ -409,13 +409,13 @@ | |||
| 										  } | ||||
| 										: { content: message.content }) | ||||
| 								})), | ||||
| 							seed: $settings.options.seed ?? undefined, | ||||
| 							stop: $settings.options.stop ?? undefined, | ||||
| 							temperature: $settings.options.temperature ?? undefined, | ||||
| 							top_p: $settings.options.top_p ?? undefined, | ||||
| 							num_ctx: $settings.options.num_ctx ?? undefined, | ||||
| 							frequency_penalty: $settings.options.repeat_penalty ?? undefined, | ||||
| 							max_tokens: $settings.options.num_predict ?? undefined | ||||
| 							seed: $settings?.options?.seed ?? undefined, | ||||
| 							stop: $settings?.options?.stop ?? undefined, | ||||
| 							temperature: $settings?.options?.temperature ?? undefined, | ||||
| 							top_p: $settings?.options?.top_p ?? undefined, | ||||
| 							num_ctx: $settings?.options?.num_ctx ?? undefined, | ||||
| 							frequency_penalty: $settings?.options?.repeat_penalty ?? undefined, | ||||
| 							max_tokens: $settings?.options?.num_predict ?? undefined | ||||
| 						}) | ||||
| 					} | ||||
| 				).catch((err) => { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Timothy J. Baek
						Timothy J. Baek