mirror of
https://github.com/open-webui/open-webui
synced 2024-11-17 22:12:51 +00:00
enh: tool id validation
This commit is contained in:
parent
dd7ac4c53a
commit
c961964647
@ -74,6 +74,12 @@ async def get_toolkits(user=Depends(get_admin_user)):
|
|||||||
|
|
||||||
@router.post("/create", response_model=Optional[ToolResponse])
|
@router.post("/create", response_model=Optional[ToolResponse])
|
||||||
async def create_new_toolkit(form_data: ToolForm, user=Depends(get_admin_user)):
|
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)
|
toolkit = Tools.get_tool_by_id(form_data.id)
|
||||||
if toolkit == None:
|
if toolkit == None:
|
||||||
toolkit_path = os.path.join(TOOLS_DIR, f"{form_data.id}.py")
|
toolkit_path = os.path.join(TOOLS_DIR, f"{form_data.id}.py")
|
||||||
|
Loading…
Reference in New Issue
Block a user