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
c9619646
Commit
c9619646
authored
Jun 10, 2024
by
Timothy J. Baek
Browse files
enh: tool id validation
parent
dd7ac4c5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
0 deletions
+6
-0
backend/apps/webui/routers/tools.py
backend/apps/webui/routers/tools.py
+6
-0
No files found.
backend/apps/webui/routers/tools.py
View file @
c9619646
...
...
@@ -74,6 +74,12 @@ async def get_toolkits(user=Depends(get_admin_user)):
@
router
.
post
(
"/create"
,
response_model
=
Optional
[
ToolResponse
])
async
def
create_new_toolkit
(
form_data
:
ToolForm
,
user
=
Depends
(
get_admin_user
)):
if
not
form_data
.
id
.
isidentifier
():
raise
HTTPException
(
status_code
=
status
.
HTTP_400_BAD_REQUEST
,
detail
=
"Only alphanumeric characters and underscores are allowed in the id"
,
)
toolkit
=
Tools
.
get_tool_by_id
(
form_data
.
id
)
if
toolkit
==
None
:
toolkit_path
=
os
.
path
.
join
(
TOOLS_DIR
,
f
"
{
form_data
.
id
}
.py"
)
...
...
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