forked from open-webui/open-webui
		
	refac
This commit is contained in:
		
							parent
							
								
									93bd20b854
								
							
						
					
					
						commit
						2fd2f792d6
					
				
					 2 changed files with 3 additions and 33 deletions
				
			
		|  | @ -3,9 +3,7 @@ | ||||||
| 	import { toast } from 'svelte-sonner'; | 	import { toast } from 'svelte-sonner'; | ||||||
| 	import { models, settings, user } from '$lib/stores'; | 	import { models, settings, user } from '$lib/stores'; | ||||||
| 
 | 
 | ||||||
| 	import { getOllamaModels } from '$lib/apis/ollama'; | 	import { getModels } from '$lib/utils'; | ||||||
| 	import { getOpenAIModels } from '$lib/apis/openai'; |  | ||||||
| 	import { getLiteLLMModels } from '$lib/apis/litellm'; |  | ||||||
| 
 | 
 | ||||||
| 	import Modal from '../common/Modal.svelte'; | 	import Modal from '../common/Modal.svelte'; | ||||||
| 	import Account from './Settings/Account.svelte'; | 	import Account from './Settings/Account.svelte'; | ||||||
|  | @ -25,37 +23,11 @@ | ||||||
| 	const saveSettings = async (updated) => { | 	const saveSettings = async (updated) => { | ||||||
| 		console.log(updated); | 		console.log(updated); | ||||||
| 		await settings.set({ ...$settings, ...updated }); | 		await settings.set({ ...$settings, ...updated }); | ||||||
| 		await models.set(await getModels()); | 		await models.set(await getModels(localStorage.token)); | ||||||
| 		localStorage.setItem('settings', JSON.stringify($settings)); | 		localStorage.setItem('settings', JSON.stringify($settings)); | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
| 	let selectedTab = 'general'; | 	let selectedTab = 'general'; | ||||||
| 
 |  | ||||||
| 	const getModels = async () => { |  | ||||||
| 		let models = await Promise.all([ |  | ||||||
| 			await getOllamaModels(localStorage.token).catch((error) => { |  | ||||||
| 				console.log(error); |  | ||||||
| 				return null; |  | ||||||
| 			}), |  | ||||||
| 			await getOpenAIModels(localStorage.token).catch((error) => { |  | ||||||
| 				console.log(error); |  | ||||||
| 				return null; |  | ||||||
| 			}), |  | ||||||
| 			await getLiteLLMModels(localStorage.token).catch((error) => { |  | ||||||
| 				console.log(error); |  | ||||||
| 				return null; |  | ||||||
| 			}) |  | ||||||
| 		]); |  | ||||||
| 
 |  | ||||||
| 		models = models |  | ||||||
| 			.filter((models) => models) |  | ||||||
| 			.reduce((a, e, i, arr) => a.concat(e, ...(i < arr.length - 1 ? [{ name: 'hr' }] : [])), []); |  | ||||||
| 
 |  | ||||||
| 		// models.push(...(ollamaModels ? [{ name: 'hr' }, ...ollamaModels] : [])); |  | ||||||
| 		// models.push(...(openAIModels ? [{ name: 'hr' }, ...openAIModels] : [])); |  | ||||||
| 		// models.push(...(liteLLMModels ? [{ name: 'hr' }, ...liteLLMModels] : [])); |  | ||||||
| 		return models; |  | ||||||
| 	}; |  | ||||||
| </script> | </script> | ||||||
| 
 | 
 | ||||||
| <Modal bind:show> | <Modal bind:show> | ||||||
|  |  | ||||||
|  | @ -20,9 +20,7 @@ export const getModels = async (token: string) => { | ||||||
| 		}) | 		}) | ||||||
| 	]); | 	]); | ||||||
| 
 | 
 | ||||||
| 	models = models | 	models = models.filter((models) => models).reduce((a, e, i, arr) => a.concat(e), []); | ||||||
| 		.filter((models) => models) |  | ||||||
| 		.reduce((a, e, i, arr) => a.concat(e, ...(i < arr.length - 1 ? [{ name: 'hr' }] : [])), []); |  | ||||||
| 
 | 
 | ||||||
| 	return models; | 	return models; | ||||||
| }; | }; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Timothy J. Baek
						Timothy J. Baek