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 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>

View file

@ -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 }))
})