forked from open-webui/open-webui
		
	Merge pull request #53 from ollama-webui/dev
feat: gpt-* model support added
This commit is contained in:
		
						commit
						597bc89f05
					
				
					 2 changed files with 9 additions and 7 deletions
				
			
		|  | @ -334,7 +334,7 @@ | |||
| 								</div> | ||||
| 							</div> | ||||
| 							<div class="mt-2 text-xs text-gray-500"> | ||||
| 								Adds optional support for 'gpt-3.5-turbo'. | ||||
| 								Adds optional support for 'gpt-*' models available. | ||||
| 							</div> | ||||
| 						</div> | ||||
| 
 | ||||
|  |  | |||
|  | @ -365,7 +365,7 @@ | |||
| 
 | ||||
| 		if (settings.OPENAI_API_KEY) { | ||||
| 			// Validate OPENAI_API_KEY | ||||
| 			const openaiModels = await fetch(`https://api.openai.com/v1/models`, { | ||||
| 			const openaiModelRes = await fetch(`https://api.openai.com/v1/models`, { | ||||
| 				method: 'GET', | ||||
| 				headers: { | ||||
| 					'Content-Type': 'application/json', | ||||
|  | @ -381,14 +381,16 @@ | |||
| 					toast.error(`OpenAI: ${error.error.message}`); | ||||
| 					return null; | ||||
| 				}); | ||||
| 
 | ||||
| 			console.log(openaiModels); | ||||
| 			const openaiModels = openaiModelRes.data; | ||||
| 
 | ||||
| 			if (openaiModels) { | ||||
| 				models = [ | ||||
| 					...(res?.models ?? []), | ||||
| 					{ name: 'hr' }, | ||||
| 					{ name: 'gpt-3.5-turbo', label: '(OpenAI)' } | ||||
| 
 | ||||
| 					...openaiModels | ||||
| 						.map((model) => ({ name: model.id, label: 'OpenAI' })) | ||||
| 						.filter((model) => model.name.includes('gpt')) | ||||
| 				]; | ||||
| 			} else { | ||||
| 				models = res?.models ?? []; | ||||
|  | @ -401,7 +403,7 @@ | |||
| 	}; | ||||
| 
 | ||||
| 	const sendPrompt = async (userPrompt) => { | ||||
| 		if (selectedModel === 'gpt-3.5-turbo') { | ||||
| 		if (selectedModel.includes('gpt-')) { | ||||
| 			await sendPromptOpenAI(userPrompt); | ||||
| 		} else { | ||||
| 			await sendPromptOllama(userPrompt); | ||||
|  | @ -532,7 +534,7 @@ | |||
| 						Authorization: `Bearer ${settings.OPENAI_API_KEY}` | ||||
| 					}, | ||||
| 					body: JSON.stringify({ | ||||
| 						model: 'gpt-3.5-turbo', | ||||
| 						model: selectedModel, | ||||
| 						stream: true, | ||||
| 						messages: messages.map((message) => ({ ...message, done: undefined })) | ||||
| 					}) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Timothy Jaeryang Baek
						Timothy Jaeryang Baek