Merge pull request #53 from ollama-webui/dev

feat: gpt-* model support added
This commit is contained in:
Timothy Jaeryang Baek 2023-11-03 21:17:01 -05:00 committed by GitHub
commit 597bc89f05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 7 deletions

View File

@ -334,7 +334,7 @@
</div> </div>
</div> </div>
<div class="mt-2 text-xs text-gray-500"> <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>
</div> </div>

View File

@ -365,7 +365,7 @@
if (settings.OPENAI_API_KEY) { if (settings.OPENAI_API_KEY) {
// Validate 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', method: 'GET',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
@ -381,14 +381,16 @@
toast.error(`OpenAI: ${error.error.message}`); toast.error(`OpenAI: ${error.error.message}`);
return null; return null;
}); });
const openaiModels = openaiModelRes.data;
console.log(openaiModels);
if (openaiModels) { if (openaiModels) {
models = [ models = [
...(res?.models ?? []), ...(res?.models ?? []),
{ name: 'hr' }, { name: 'hr' },
{ name: 'gpt-3.5-turbo', label: '(OpenAI)' }
...openaiModels
.map((model) => ({ name: model.id, label: 'OpenAI' }))
.filter((model) => model.name.includes('gpt'))
]; ];
} else { } else {
models = res?.models ?? []; models = res?.models ?? [];
@ -401,7 +403,7 @@
}; };
const sendPrompt = async (userPrompt) => { const sendPrompt = async (userPrompt) => {
if (selectedModel === 'gpt-3.5-turbo') { if (selectedModel.includes('gpt-')) {
await sendPromptOpenAI(userPrompt); await sendPromptOpenAI(userPrompt);
} else { } else {
await sendPromptOllama(userPrompt); await sendPromptOllama(userPrompt);
@ -532,7 +534,7 @@
Authorization: `Bearer ${settings.OPENAI_API_KEY}` Authorization: `Bearer ${settings.OPENAI_API_KEY}`
}, },
body: JSON.stringify({ body: JSON.stringify({
model: 'gpt-3.5-turbo', model: selectedModel,
stream: true, stream: true,
messages: messages.map((message) => ({ ...message, done: undefined })) messages: messages.map((message) => ({ ...message, done: undefined }))
}) })