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
c1fd55bb
Commit
c1fd55bb
authored
Jul 28, 2024
by
Timothy J. Baek
Browse files
fix/refac: actions
parent
77b2d2db
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
39 deletions
+28
-39
backend/main.py
backend/main.py
+28
-39
No files found.
backend/main.py
View file @
c1fd55bb
...
@@ -991,32 +991,15 @@ async def get_all_models():
...
@@ -991,32 +991,15 @@ async def get_all_models():
model
[
"name"
]
=
custom_model
.
name
model
[
"name"
]
=
custom_model
.
name
model
[
"info"
]
=
custom_model
.
model_dump
()
model
[
"info"
]
=
custom_model
.
model_dump
()
action_ids
=
[]
+
global_action_ids
action_ids
=
[]
if
"info"
in
model
and
"meta"
in
model
[
"info"
]:
if
"info"
in
model
and
"meta"
in
model
[
"info"
]:
action_ids
.
extend
(
model
[
"info"
][
"meta"
].
get
(
"actionIds"
,
[]))
action_ids
.
extend
(
model
[
"info"
][
"meta"
].
get
(
"actionIds"
,
[]))
action_ids
=
list
(
set
(
action_ids
))
action_ids
=
[
action_id
for
action_id
in
action_ids
if
action_id
in
enabled_action_ids
]
model
[
"actions"
]
=
[]
for
action_id
in
action_ids
:
action
=
Functions
.
get_function_by_id
(
action_id
)
model
[
"actions"
].
append
(
{
"id"
:
action_id
,
"name"
:
action
.
name
,
"description"
:
action
.
meta
.
description
,
"icon_url"
:
action
.
meta
.
manifest
.
get
(
"icon_url"
,
None
),
}
)
model
[
"action_ids"
]
=
action_ids
else
:
else
:
owned_by
=
"openai"
owned_by
=
"openai"
pipe
=
None
pipe
=
None
actions
=
[]
action
_id
s
=
[]
for
model
in
models
:
for
model
in
models
:
if
(
if
(
...
@@ -1027,26 +1010,8 @@ async def get_all_models():
...
@@ -1027,26 +1010,8 @@ async def get_all_models():
if
"pipe"
in
model
:
if
"pipe"
in
model
:
pipe
=
model
[
"pipe"
]
pipe
=
model
[
"pipe"
]
action_ids
=
[]
+
global_action_ids
if
"info"
in
model
and
"meta"
in
model
[
"info"
]:
if
"info"
in
model
and
"meta"
in
model
[
"info"
]:
action_ids
.
extend
(
model
[
"info"
][
"meta"
].
get
(
"actionIds"
,
[]))
action_ids
.
extend
(
model
[
"info"
][
"meta"
].
get
(
"actionIds"
,
[]))
action_ids
=
list
(
set
(
action_ids
))
action_ids
=
[
action_id
for
action_id
in
action_ids
if
action_id
in
enabled_action_ids
]
actions
=
[
{
"id"
:
action_id
,
"name"
:
Functions
.
get_function_by_id
(
action_id
).
name
,
"description"
:
Functions
.
get_function_by_id
(
action_id
).
meta
.
description
,
}
for
action_id
in
action_ids
]
break
break
models
.
append
(
models
.
append
(
...
@@ -1059,7 +1024,31 @@ async def get_all_models():
...
@@ -1059,7 +1024,31 @@ async def get_all_models():
"info"
:
custom_model
.
model_dump
(),
"info"
:
custom_model
.
model_dump
(),
"preset"
:
True
,
"preset"
:
True
,
**
({
"pipe"
:
pipe
}
if
pipe
is
not
None
else
{}),
**
({
"pipe"
:
pipe
}
if
pipe
is
not
None
else
{}),
"actions"
:
actions
,
"action_ids"
:
action_ids
,
}
)
for
model
in
models
:
action_ids
=
[]
if
"action_ids"
in
model
:
action_ids
=
model
[
"action_ids"
]
del
model
[
"action_ids"
]
action_ids
=
action_ids
+
global_action_ids
action_ids
=
list
(
set
(
action_ids
))
action_ids
=
[
action_id
for
action_id
in
action_ids
if
action_id
in
enabled_action_ids
]
model
[
"actions"
]
=
[]
for
action_id
in
action_ids
:
action
=
Functions
.
get_function_by_id
(
action_id
)
model
[
"actions"
].
append
(
{
"id"
:
action_id
,
"name"
:
action
.
name
,
"description"
:
action
.
meta
.
description
,
"icon_url"
:
action
.
meta
.
manifest
.
get
(
"icon_url"
,
None
),
}
}
)
)
...
...
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