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
3aa6b0fe
"profiler/vscode:/vscode.git/clone" did not exist on "0601203a70f2334fc7b72a86377990810c7b7ab7"
Commit
3aa6b0fe
authored
May 17, 2024
by
Timothy J. Baek
Browse files
fix: model filter issue
parent
3890ea14
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
18 deletions
+21
-18
backend/apps/litellm/main.py
backend/apps/litellm/main.py
+4
-4
backend/apps/ollama/main.py
backend/apps/ollama/main.py
+8
-6
backend/apps/openai/main.py
backend/apps/openai/main.py
+5
-4
backend/main.py
backend/main.py
+4
-4
No files found.
backend/apps/litellm/main.py
View file @
3aa6b0fe
...
...
@@ -75,6 +75,10 @@ with open(LITELLM_CONFIG_DIR, "r") as file:
litellm_config
=
yaml
.
safe_load
(
file
)
app
.
state
.
ENABLE_MODEL_FILTER
=
ENABLE_MODEL_FILTER
app
.
state
.
MODEL_FILTER_LIST
=
MODEL_FILTER_LIST
app
.
state
.
ENABLE
=
ENABLE_LITELLM
app
.
state
.
CONFIG
=
litellm_config
...
...
@@ -151,10 +155,6 @@ async def shutdown_litellm_background():
background_process
=
None
app
.
state
.
ENABLE_MODEL_FILTER
=
ENABLE_MODEL_FILTER
app
.
state
.
MODEL_FILTER_LIST
=
MODEL_FILTER_LIST
@
app
.
get
(
"/"
)
async
def
get_status
():
return
{
"status"
:
True
}
...
...
backend/apps/ollama/main.py
View file @
3aa6b0fe
...
...
@@ -64,8 +64,8 @@ app.add_middleware(
app
.
state
.
config
=
AppConfig
()
app
.
state
.
ENABLE_MODEL_FILTER
=
ENABLE_MODEL_FILTER
app
.
state
.
MODEL_FILTER_LIST
=
MODEL_FILTER_LIST
app
.
state
.
config
.
ENABLE_MODEL_FILTER
=
ENABLE_MODEL_FILTER
app
.
state
.
config
.
MODEL_FILTER_LIST
=
MODEL_FILTER_LIST
app
.
state
.
config
.
OLLAMA_BASE_URLS
=
OLLAMA_BASE_URLS
app
.
state
.
MODELS
=
{}
...
...
@@ -178,11 +178,12 @@ async def get_ollama_tags(
if
url_idx
==
None
:
models
=
await
get_all_models
()
if
app
.
state
.
ENABLE_MODEL_FILTER
:
if
app
.
state
.
config
.
ENABLE_MODEL_FILTER
:
if
user
.
role
==
"user"
:
models
[
"models"
]
=
list
(
filter
(
lambda
model
:
model
[
"name"
]
in
app
.
state
.
MODEL_FILTER_LIST
,
lambda
model
:
model
[
"name"
]
in
app
.
state
.
config
.
MODEL_FILTER_LIST
,
models
[
"models"
],
)
)
...
...
@@ -1046,11 +1047,12 @@ async def get_openai_models(
if
url_idx
==
None
:
models
=
await
get_all_models
()
if
app
.
state
.
ENABLE_MODEL_FILTER
:
if
app
.
state
.
config
.
ENABLE_MODEL_FILTER
:
if
user
.
role
==
"user"
:
models
[
"models"
]
=
list
(
filter
(
lambda
model
:
model
[
"name"
]
in
app
.
state
.
MODEL_FILTER_LIST
,
lambda
model
:
model
[
"name"
]
in
app
.
state
.
config
.
MODEL_FILTER_LIST
,
models
[
"models"
],
)
)
...
...
backend/apps/openai/main.py
View file @
3aa6b0fe
...
...
@@ -47,10 +47,11 @@ app.add_middleware(
allow_headers
=
[
"*"
],
)
app
.
state
.
config
=
AppConfig
()
app
.
state
.
ENABLE_MODEL_FILTER
=
ENABLE_MODEL_FILTER
app
.
state
.
MODEL_FILTER_LIST
=
MODEL_FILTER_LIST
app
.
state
.
config
.
ENABLE_MODEL_FILTER
=
ENABLE_MODEL_FILTER
app
.
state
.
config
.
MODEL_FILTER_LIST
=
MODEL_FILTER_LIST
app
.
state
.
config
.
ENABLE_OPENAI_API
=
ENABLE_OPENAI_API
...
...
@@ -259,11 +260,11 @@ async def get_all_models():
async
def
get_models
(
url_idx
:
Optional
[
int
]
=
None
,
user
=
Depends
(
get_current_user
)):
if
url_idx
==
None
:
models
=
await
get_all_models
()
if
app
.
state
.
ENABLE_MODEL_FILTER
:
if
app
.
state
.
config
.
ENABLE_MODEL_FILTER
:
if
user
.
role
==
"user"
:
models
[
"data"
]
=
list
(
filter
(
lambda
model
:
model
[
"id"
]
in
app
.
state
.
MODEL_FILTER_LIST
,
lambda
model
:
model
[
"id"
]
in
app
.
state
.
config
.
MODEL_FILTER_LIST
,
models
[
"data"
],
)
)
...
...
backend/main.py
View file @
3aa6b0fe
...
...
@@ -292,11 +292,11 @@ async def update_model_filter_config(
app
.
state
.
config
.
ENABLE_MODEL_FILTER
=
form_data
.
enabled
app
.
state
.
config
.
MODEL_FILTER_LIST
=
form_data
.
models
ollama_app
.
state
.
ENABLE_MODEL_FILTER
=
app
.
state
.
config
.
ENABLE_MODEL_FILTER
ollama_app
.
state
.
MODEL_FILTER_LIST
=
app
.
state
.
config
.
MODEL_FILTER_LIST
ollama_app
.
state
.
config
.
ENABLE_MODEL_FILTER
=
app
.
state
.
config
.
ENABLE_MODEL_FILTER
ollama_app
.
state
.
config
.
MODEL_FILTER_LIST
=
app
.
state
.
config
.
MODEL_FILTER_LIST
openai_app
.
state
.
ENABLE_MODEL_FILTER
=
app
.
state
.
config
.
ENABLE_MODEL_FILTER
openai_app
.
state
.
MODEL_FILTER_LIST
=
app
.
state
.
config
.
MODEL_FILTER_LIST
openai_app
.
state
.
config
.
ENABLE_MODEL_FILTER
=
app
.
state
.
config
.
ENABLE_MODEL_FILTER
openai_app
.
state
.
config
.
MODEL_FILTER_LIST
=
app
.
state
.
config
.
MODEL_FILTER_LIST
litellm_app
.
state
.
ENABLE_MODEL_FILTER
=
app
.
state
.
config
.
ENABLE_MODEL_FILTER
litellm_app
.
state
.
MODEL_FILTER_LIST
=
app
.
state
.
config
.
MODEL_FILTER_LIST
...
...
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