refac
This commit is contained in:
1 parent
a0c2ec3d2c
commit
91762ed807
8 files changed
+77
-78
No files matched your search
@@ -22,6 +22,7 @@ from open_webui.models.functions import (
|
||||
)
|
||||
from open_webui.utils.auth import get_admin_user, get_verified_user
|
||||
from open_webui.utils.plugin import (
|
||||
get_functions_cache,
|
||||
get_function_module_from_cache,
|
||||
load_function_module_by_id,
|
||||
replace_imports,
|
||||
@@ -205,7 +206,7 @@ async def create_new_function(
|
||||
)
|
||||
form_data.meta.manifest = frontmatter
|
||||
|
||||
FUNCTIONS = request.app.state.FUNCTIONS
|
||||
FUNCTIONS = get_functions_cache(request)
|
||||
FUNCTIONS[form_data.id] = function_module
|
||||
|
||||
function = await Functions.insert_new_function(user.id, function_type, form_data, db=db)
|
||||
@@ -322,7 +323,7 @@ async def update_function_by_id(
|
||||
function_module, function_type, frontmatter = await load_function_module_by_id(id, content=form_data.content)
|
||||
form_data.meta.manifest = frontmatter
|
||||
|
||||
FUNCTIONS = request.app.state.FUNCTIONS
|
||||
FUNCTIONS = get_functions_cache(request)
|
||||
FUNCTIONS[id] = function_module
|
||||
|
||||
updated = {**form_data.model_dump(exclude={'id'}), 'type': function_type}
|
||||
@@ -363,9 +364,8 @@ async def delete_function_by_id(
|
||||
result = await Functions.delete_function_by_id(id, db=db)
|
||||
|
||||
if result:
|
||||
FUNCTIONS = request.app.state.FUNCTIONS
|
||||
if id in FUNCTIONS:
|
||||
del FUNCTIONS[id]
|
||||
FUNCTIONS = get_functions_cache(request)
|
||||
FUNCTIONS.pop(id, None)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
Reference in new issue
Block a user