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
144581a7
"web/scripts/vscode:/vscode.git/clone" did not exist on "ab76abc7676ea30726661b85c4fb85f84a3ff5aa"
Commit
144581a7
authored
Jul 09, 2024
by
Michael Poluektov
Browse files
refac: get_sorted_pipelines()
parent
7ffd75b9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
29 deletions
+12
-29
backend/main.py
backend/main.py
+12
-29
No files found.
backend/main.py
View file @
144581a7
...
...
@@ -764,9 +764,7 @@ app.add_middleware(ChatCompletionMiddleware)
##################################
def
filter_pipeline
(
payload
,
user
):
user
=
{
"id"
:
user
.
id
,
"email"
:
user
.
email
,
"name"
:
user
.
name
,
"role"
:
user
.
role
}
model_id
=
payload
[
"model"
]
def
get_sorted_filters
(
model_id
):
filters
=
[
model
for
model
in
app
.
state
.
MODELS
.
values
()
...
...
@@ -782,6 +780,13 @@ def filter_pipeline(payload, user):
)
]
sorted_filters
=
sorted
(
filters
,
key
=
lambda
x
:
x
[
"pipeline"
][
"priority"
])
return
sorted_filters
def
filter_pipeline
(
payload
,
user
):
user
=
{
"id"
:
user
.
id
,
"email"
:
user
.
email
,
"name"
:
user
.
name
,
"role"
:
user
.
role
}
model_id
=
payload
[
"model"
]
sorted_filters
=
get_sorted_filters
(
model_id
)
model
=
app
.
state
.
MODELS
[
model_id
]
...
...
@@ -814,19 +819,12 @@ def filter_pipeline(payload, user):
print
(
f
"Connection error:
{
e
}
"
)
if
r
is
not
None
:
try
:
res
=
r
.
json
()
except
:
pass
res
=
r
.
json
()
if
"detail"
in
res
:
raise
Exception
(
r
.
status_code
,
res
[
"detail"
])
else
:
pass
if
"pipeline"
not
in
app
.
state
.
MODELS
[
model_id
]:
if
"task"
in
payload
:
del
payload
[
"task"
]
if
"pipeline"
not
in
app
.
state
.
MODELS
[
model_id
]
and
"task"
in
payload
:
del
payload
[
"task"
]
return
payload
...
...
@@ -1061,22 +1059,7 @@ async def chat_completed(form_data: dict, user=Depends(get_verified_user)):
)
model
=
app
.
state
.
MODELS
[
model_id
]
filters
=
[
model
for
model
in
app
.
state
.
MODELS
.
values
()
if
"pipeline"
in
model
and
"type"
in
model
[
"pipeline"
]
and
model
[
"pipeline"
][
"type"
]
==
"filter"
and
(
model
[
"pipeline"
][
"pipelines"
]
==
[
"*"
]
or
any
(
model_id
==
target_model_id
for
target_model_id
in
model
[
"pipeline"
][
"pipelines"
]
)
)
]
sorted_filters
=
sorted
(
filters
,
key
=
lambda
x
:
x
[
"pipeline"
][
"priority"
])
sorted_filters
=
get_sorted_filters
(
model_id
)
if
"pipeline"
in
model
:
sorted_filters
=
[
model
]
+
sorted_filters
...
...
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