Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
3b3b7fb4
Commit
3b3b7fb4
authored
Nov 06, 2023
by
Timothy J. Baek
Browse files
fix: ollama custom url support
parent
c8cab48a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
34 deletions
+39
-34
src/lib/components/chat/SettingsModal.svelte
src/lib/components/chat/SettingsModal.svelte
+2
-2
src/routes/+page.svelte
src/routes/+page.svelte
+37
-32
No files found.
src/lib/components/chat/SettingsModal.svelte
View file @
3b3b7fb4
...
@@ -65,7 +65,7 @@
...
@@ -65,7 +65,7 @@
if (API_BASE_URL === '') {
if (API_BASE_URL === '') {
API_BASE_URL = BUILD_TIME_API_BASE_URL;
API_BASE_URL = BUILD_TIME_API_BASE_URL;
}
}
const res = await getModelTags(API_BASE_URL);
const res = await getModelTags(API_BASE_URL
, 'ollama'
);
if (res) {
if (res) {
toast.success('Server connection verified');
toast.success('Server connection verified');
...
@@ -774,7 +774,7 @@
...
@@ -774,7 +774,7 @@
<div>
<div>
<a href="https://github.com/ollama-webui/ollama-webui">
<a href="https://github.com/ollama-webui/ollama-webui">
<img
<img
alt="
followers
"
alt="
Github Repo
"
src="https://img.shields.io/github/stars/ollama-webui/ollama-webui?style=social&label=Star us on Github"
src="https://img.shields.io/github/stars/ollama-webui/ollama-webui?style=social&label=Star us on Github"
/>
/>
</a>
</a>
...
...
src/routes/+page.svelte
View file @
3b3b7fb4
...
@@ -236,6 +236,7 @@
...
@@ -236,6 +236,7 @@
console
.
log
(
updated
);
console
.
log
(
updated
);
settings
=
{
...
settings
,
...
updated
};
settings
=
{
...
settings
,
...
updated
};
localStorage
.
setItem
(
'
settings
'
,
JSON
.
stringify
(
settings
));
localStorage
.
setItem
(
'
settings
'
,
JSON
.
stringify
(
settings
));
API_BASE_URL
=
updated
?.
API_BASE_URL
??
API_BASE_URL
;
await
getModelTags
();
await
getModelTags
();
};
};
...
@@ -374,7 +375,7 @@
...
@@ -374,7 +375,7 @@
// Ollama functions
// Ollama functions
//////////////////////////
//////////////////////////
const
getModelTags
=
async
(
url
=
null
)
=>
{
const
getModelTags
=
async
(
url
=
null
,
type
=
'
all
'
)
=>
{
const
res
=
await
fetch
(
`
${
url
===
null
?
API_BASE_URL
:
url
}
/tags`
,
{
const
res
=
await
fetch
(
`
${
url
===
null
?
API_BASE_URL
:
url
}
/tags`
,
{
method
:
'
GET
'
,
method
:
'
GET
'
,
headers
:
{
headers
:
{
...
@@ -394,43 +395,47 @@
...
@@ -394,43 +395,47 @@
console
.
log
(
res
);
console
.
log
(
res
);
if
(
settings
.
OPENAI_API_KEY
)
{
if
(
type
===
'
all
'
)
{
// Validate OPENAI_API_KEY
if
(
settings
.
OPENAI_API_KEY
)
{
const
openaiModelRes
=
await
fetch
(
`https://api.openai.com/v1/models`
,
{
// Validate OPENAI_API_KEY
method
:
'
GET
'
,
const
openaiModelRes
=
await
fetch
(
`https://api.openai.com/v1/models`
,
{
headers
:
{
method
:
'
GET
'
,
'
Content-Type
'
:
'
application/json
'
,
headers
:
{
Authorization
:
`Bearer
${
settings
.
OPENAI_API_KEY
}
`
'
Content-Type
'
:
'
application/json
'
,
}
Authorization
:
`Bearer
${
settings
.
OPENAI_API_KEY
}
`
})
}
.
then
(
async
(
res
)
=>
{
if
(
!
res
.
ok
)
throw
await
res
.
json
();
return
res
.
json
();
})
})
.
catch
((
error
)
=>
{
.
then
(
async
(
res
)
=>
{
console
.
log
(
error
);
if
(
!
res
.
ok
)
throw
await
res
.
json
();
toast
.
error
(
`OpenAI:
${
error
?.
error
?.
message
??
'
Network Problem
'
}
`);
return
res
.
json
();
return null;
})
});
.
catch
((
error
)
=>
{
const openaiModels = openaiModelRes?.data ?? null;
console
.
log
(
error
);
toast
.
error
(
`OpenAI:
${
error
?.
error
?.
message
??
'
Network Problem
'
}
`);
if (openaiModels) {
return null;
models = [
});
...(res?.models ?? []),
const openaiModels = openaiModelRes?.data ?? null;
{ name: 'hr' },
if (openaiModels) {
...openaiModels
models = [
.map((model) => ({ name: model.id, label: 'OpenAI' }))
...(res?.models ?? []),
.filter((model) => model.name.includes('gpt'))
{ name: 'hr' },
];
...openaiModels
.map((model) => ({ name: model.id, label: 'OpenAI' }))
.filter((model) => model.name.includes('gpt'))
];
} else {
models = res?.models ?? [];
}
} else {
} else {
models = res?.models ?? [];
models = res?.models ?? [];
}
}
return models;
} else {
} else {
models =
res?.models ??
[]
;
return
res?.models ??
null
;
}
}
return models;
};
};
const sendPrompt = async (userPrompt) => {
const sendPrompt = async (userPrompt) => {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment