mirror of
https://github.com/open-webui/open-webui
synced 2024-11-16 13:40:55 +00:00
refac
This commit is contained in:
parent
cf86ba7786
commit
f2f713023d
@ -56,11 +56,11 @@ async def create_new_function(
|
||||
function = Functions.get_function_by_id(form_data.id)
|
||||
if function is None:
|
||||
try:
|
||||
form_data.content = replace_imports(form_data.content)
|
||||
function_module, function_type, frontmatter = load_function_module_by_id(
|
||||
form_data.id,
|
||||
content=form_data.content,
|
||||
)
|
||||
form_data.content = replace_imports(form_data.content)
|
||||
form_data.meta.manifest = frontmatter
|
||||
|
||||
FUNCTIONS = request.app.state.FUNCTIONS
|
||||
@ -173,10 +173,10 @@ async def update_function_by_id(
|
||||
request: Request, id: str, form_data: FunctionForm, user=Depends(get_admin_user)
|
||||
):
|
||||
try:
|
||||
form_data.content = replace_imports(form_data.content)
|
||||
function_module, function_type, frontmatter = load_function_module_by_id(
|
||||
id, content=form_data.content
|
||||
)
|
||||
form_data.content = replace_imports(form_data.content)
|
||||
form_data.meta.manifest = frontmatter
|
||||
|
||||
FUNCTIONS = request.app.state.FUNCTIONS
|
||||
|
@ -60,10 +60,10 @@ async def create_new_toolkit(
|
||||
toolkit = Tools.get_tool_by_id(form_data.id)
|
||||
if toolkit is None:
|
||||
try:
|
||||
form_data.content = replace_imports(form_data.content)
|
||||
toolkit_module, frontmatter = load_toolkit_module_by_id(
|
||||
form_data.id, content=form_data.content
|
||||
)
|
||||
form_data.content = replace_imports(form_data.content)
|
||||
form_data.meta.manifest = frontmatter
|
||||
|
||||
TOOLS = request.app.state.TOOLS
|
||||
@ -126,10 +126,10 @@ async def update_toolkit_by_id(
|
||||
user=Depends(get_admin_user),
|
||||
):
|
||||
try:
|
||||
form_data.content = replace_imports(form_data.content)
|
||||
toolkit_module, frontmatter = load_toolkit_module_by_id(
|
||||
id, content=form_data.content
|
||||
)
|
||||
form_data.content = replace_imports(form_data.content)
|
||||
form_data.meta.manifest = frontmatter
|
||||
|
||||
TOOLS = request.app.state.TOOLS
|
||||
|
@ -76,8 +76,8 @@ def load_toolkit_module_by_id(toolkit_id, content=None):
|
||||
|
||||
content = tool.content
|
||||
|
||||
content = replace_imports(content)
|
||||
Tools.update_tool_by_id(toolkit_id, {"content": content})
|
||||
content = replace_imports(content)
|
||||
Tools.update_tool_by_id(toolkit_id, {"content": content})
|
||||
|
||||
module_name = f"{toolkit_id}"
|
||||
module = types.ModuleType(module_name)
|
||||
@ -114,9 +114,8 @@ def load_function_module_by_id(function_id, content=None):
|
||||
raise Exception(f"Function not found: {function_id}")
|
||||
content = function.content
|
||||
|
||||
# Replace the module paths in the function content
|
||||
content = replace_imports(content)
|
||||
Functions.update_function_by_id(function_id, {"content": content})
|
||||
content = replace_imports(content)
|
||||
Functions.update_function_by_id(function_id, {"content": content})
|
||||
|
||||
module_name = f"{function_id}"
|
||||
module = types.ModuleType(module_name)
|
||||
|
Loading…
Reference in New Issue
Block a user