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
7ae4669f
Unverified
Commit
7ae4669f
authored
Mar 10, 2024
by
Timothy Jaeryang Baek
Committed by
GitHub
Mar 10, 2024
Browse files
Merge pull request #1131 from open-webui/dev
fix: env var migration issue
parents
11ca2703
e3fc9724
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
18 deletions
+23
-18
backend/apps/openai/main.py
backend/apps/openai/main.py
+18
-12
backend/config.py
backend/config.py
+5
-6
No files found.
backend/apps/openai/main.py
View file @
7ae4669f
...
...
@@ -179,12 +179,18 @@ def merge_models_lists(model_lists):
async
def
get_all_models
():
print
(
"get_all_models"
)
if
len
(
app
.
state
.
OPENAI_API_KEYS
)
==
1
and
app
.
state
.
OPENAI_API_KEYS
[
0
]
==
""
:
models
=
{
"data"
:
[]}
else
:
tasks
=
[
fetch_url
(
f
"
{
url
}
/models"
,
app
.
state
.
OPENAI_API_KEYS
[
idx
])
for
idx
,
url
in
enumerate
(
app
.
state
.
OPENAI_API_BASE_URLS
)
]
responses
=
await
asyncio
.
gather
(
*
tasks
)
responses
=
list
(
filter
(
lambda
x
:
x
is
not
None
and
"error"
not
in
x
,
responses
))
responses
=
list
(
filter
(
lambda
x
:
x
is
not
None
and
"error"
not
in
x
,
responses
)
)
models
=
{
"data"
:
merge_models_lists
(
list
(
map
(
lambda
response
:
response
[
"data"
],
responses
))
...
...
backend/config.py
View file @
7ae4669f
...
...
@@ -209,10 +209,6 @@ OLLAMA_API_BASE_URL = os.environ.get(
OLLAMA_BASE_URL
=
os
.
environ
.
get
(
"OLLAMA_BASE_URL"
,
""
)
if
ENV
==
"prod"
:
if
OLLAMA_BASE_URL
==
"/ollama"
:
OLLAMA_BASE_URL
=
"http://host.docker.internal:11434"
if
OLLAMA_BASE_URL
==
""
and
OLLAMA_API_BASE_URL
!=
""
:
OLLAMA_BASE_URL
=
(
...
...
@@ -221,6 +217,11 @@ if OLLAMA_BASE_URL == "" and OLLAMA_API_BASE_URL != "":
else
OLLAMA_API_BASE_URL
)
if
ENV
==
"prod"
:
if
OLLAMA_BASE_URL
==
"/ollama"
:
OLLAMA_BASE_URL
=
"http://host.docker.internal:11434"
OLLAMA_BASE_URLS
=
os
.
environ
.
get
(
"OLLAMA_BASE_URLS"
,
""
)
OLLAMA_BASE_URLS
=
OLLAMA_BASE_URLS
if
OLLAMA_BASE_URLS
!=
""
else
OLLAMA_BASE_URL
...
...
@@ -234,8 +235,6 @@ OLLAMA_BASE_URLS = [url.strip() for url in OLLAMA_BASE_URLS.split(";")]
OPENAI_API_KEY
=
os
.
environ
.
get
(
"OPENAI_API_KEY"
,
""
)
OPENAI_API_BASE_URL
=
os
.
environ
.
get
(
"OPENAI_API_BASE_URL"
,
""
)
if
OPENAI_API_KEY
==
""
:
OPENAI_API_KEY
=
"none"
if
OPENAI_API_BASE_URL
==
""
:
OPENAI_API_BASE_URL
=
"https://api.openai.com/v1"
...
...
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