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
b4c770d7
Commit
b4c770d7
authored
Mar 10, 2024
by
Timothy J. Baek
Browse files
fix: disable openai model by default
parent
8df6b137
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
14 deletions
+18
-14
backend/apps/openai/main.py
backend/apps/openai/main.py
+18
-12
backend/config.py
backend/config.py
+0
-2
No files found.
backend/apps/openai/main.py
View file @
b4c770d7
...
@@ -179,20 +179,26 @@ def merge_models_lists(model_lists):
...
@@ -179,20 +179,26 @@ def merge_models_lists(model_lists):
async
def
get_all_models
():
async
def
get_all_models
():
print
(
"get_all_models"
)
print
(
"get_all_models"
)
tasks
=
[
fetch_url
(
f
"
{
url
}
/models"
,
app
.
state
.
OPENAI_API_KEYS
[
idx
])
if
len
(
app
.
state
.
OPENAI_API_KEYS
)
==
1
and
app
.
state
.
OPENAI_API_KEYS
[
0
]
==
""
:
for
idx
,
url
in
enumerate
(
app
.
state
.
OPENAI_API_BASE_URLS
)
models
=
{
"data"
:
[]}
]
else
:
responses
=
await
asyncio
.
gather
(
*
tasks
)
tasks
=
[
responses
=
list
(
filter
(
lambda
x
:
x
is
not
None
and
"error"
not
in
x
,
responses
))
fetch_url
(
f
"
{
url
}
/models"
,
app
.
state
.
OPENAI_API_KEYS
[
idx
])
models
=
{
for
idx
,
url
in
enumerate
(
app
.
state
.
OPENAI_API_BASE_URLS
)
"data"
:
merge_models_lists
(
]
list
(
map
(
lambda
response
:
response
[
"data"
],
responses
))
responses
=
await
asyncio
.
gather
(
*
tasks
)
responses
=
list
(
filter
(
lambda
x
:
x
is
not
None
and
"error"
not
in
x
,
responses
)
)
)
}
models
=
{
app
.
state
.
MODELS
=
{
model
[
"id"
]:
model
for
model
in
models
[
"data"
]}
"data"
:
merge_models_lists
(
list
(
map
(
lambda
response
:
response
[
"data"
],
responses
))
)
}
app
.
state
.
MODELS
=
{
model
[
"id"
]:
model
for
model
in
models
[
"data"
]}
return
models
return
models
@
app
.
get
(
"/models"
)
@
app
.
get
(
"/models"
)
...
...
backend/config.py
View file @
b4c770d7
...
@@ -234,8 +234,6 @@ OLLAMA_BASE_URLS = [url.strip() for url in OLLAMA_BASE_URLS.split(";")]
...
@@ -234,8 +234,6 @@ OLLAMA_BASE_URLS = [url.strip() for url in OLLAMA_BASE_URLS.split(";")]
OPENAI_API_KEY
=
os
.
environ
.
get
(
"OPENAI_API_KEY"
,
""
)
OPENAI_API_KEY
=
os
.
environ
.
get
(
"OPENAI_API_KEY"
,
""
)
OPENAI_API_BASE_URL
=
os
.
environ
.
get
(
"OPENAI_API_BASE_URL"
,
""
)
OPENAI_API_BASE_URL
=
os
.
environ
.
get
(
"OPENAI_API_BASE_URL"
,
""
)
if
OPENAI_API_KEY
==
""
:
OPENAI_API_KEY
=
"none"
if
OPENAI_API_BASE_URL
==
""
:
if
OPENAI_API_BASE_URL
==
""
:
OPENAI_API_BASE_URL
=
"https://api.openai.com/v1"
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