forked from open-webui/open-webui
Merge pull request #70 from ollama-webui/dev
fix: ollama custom url support
This commit is contained in:
commit
9a6919331a
2 changed files with 38 additions and 33 deletions
|
@ -65,7 +65,7 @@
|
|||
if (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) {
|
||||
toast.success('Server connection verified');
|
||||
|
@ -774,7 +774,7 @@
|
|||
<div>
|
||||
<a href="https://github.com/ollama-webui/ollama-webui">
|
||||
<img
|
||||
alt="followers"
|
||||
alt="Github Repo"
|
||||
src="https://img.shields.io/github/stars/ollama-webui/ollama-webui?style=social&label=Star us on Github"
|
||||
/>
|
||||
</a>
|
||||
|
|
|
@ -236,6 +236,7 @@
|
|||
console.log(updated);
|
||||
settings = { ...settings, ...updated };
|
||||
localStorage.setItem('settings', JSON.stringify(settings));
|
||||
API_BASE_URL = updated?.API_BASE_URL ?? API_BASE_URL;
|
||||
await getModelTags();
|
||||
};
|
||||
|
||||
|
@ -374,7 +375,7 @@
|
|||
// 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`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
|
@ -394,6 +395,7 @@
|
|||
|
||||
console.log(res);
|
||||
|
||||
if (type === 'all') {
|
||||
if (settings.OPENAI_API_KEY) {
|
||||
// Validate OPENAI_API_KEY
|
||||
const openaiModelRes = await fetch(`https://api.openai.com/v1/models`, {
|
||||
|
@ -431,6 +433,9 @@
|
|||
}
|
||||
|
||||
return models;
|
||||
} else {
|
||||
return res?.models ?? null;
|
||||
}
|
||||
};
|
||||
|
||||
const sendPrompt = async (userPrompt) => {
|
||||
|
|
Loading…
Reference in a new issue