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)
|
function = Functions.get_function_by_id(form_data.id)
|
||||||
if function is None:
|
if function is None:
|
||||||
try:
|
try:
|
||||||
|
form_data.content = replace_imports(form_data.content)
|
||||||
function_module, function_type, frontmatter = load_function_module_by_id(
|
function_module, function_type, frontmatter = load_function_module_by_id(
|
||||||
form_data.id,
|
form_data.id,
|
||||||
content=form_data.content,
|
content=form_data.content,
|
||||||
)
|
)
|
||||||
form_data.content = replace_imports(form_data.content)
|
|
||||||
form_data.meta.manifest = frontmatter
|
form_data.meta.manifest = frontmatter
|
||||||
|
|
||||||
FUNCTIONS = request.app.state.FUNCTIONS
|
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)
|
request: Request, id: str, form_data: FunctionForm, user=Depends(get_admin_user)
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
form_data.content = replace_imports(form_data.content)
|
||||||
function_module, function_type, frontmatter = load_function_module_by_id(
|
function_module, function_type, frontmatter = load_function_module_by_id(
|
||||||
id, content=form_data.content
|
id, content=form_data.content
|
||||||
)
|
)
|
||||||
form_data.content = replace_imports(form_data.content)
|
|
||||||
form_data.meta.manifest = frontmatter
|
form_data.meta.manifest = frontmatter
|
||||||
|
|
||||||
FUNCTIONS = request.app.state.FUNCTIONS
|
FUNCTIONS = request.app.state.FUNCTIONS
|
||||||
|
@ -60,10 +60,10 @@ async def create_new_toolkit(
|
|||||||
toolkit = Tools.get_tool_by_id(form_data.id)
|
toolkit = Tools.get_tool_by_id(form_data.id)
|
||||||
if toolkit is None:
|
if toolkit is None:
|
||||||
try:
|
try:
|
||||||
|
form_data.content = replace_imports(form_data.content)
|
||||||
toolkit_module, frontmatter = load_toolkit_module_by_id(
|
toolkit_module, frontmatter = load_toolkit_module_by_id(
|
||||||
form_data.id, content=form_data.content
|
form_data.id, content=form_data.content
|
||||||
)
|
)
|
||||||
form_data.content = replace_imports(form_data.content)
|
|
||||||
form_data.meta.manifest = frontmatter
|
form_data.meta.manifest = frontmatter
|
||||||
|
|
||||||
TOOLS = request.app.state.TOOLS
|
TOOLS = request.app.state.TOOLS
|
||||||
@ -126,10 +126,10 @@ async def update_toolkit_by_id(
|
|||||||
user=Depends(get_admin_user),
|
user=Depends(get_admin_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
form_data.content = replace_imports(form_data.content)
|
||||||
toolkit_module, frontmatter = load_toolkit_module_by_id(
|
toolkit_module, frontmatter = load_toolkit_module_by_id(
|
||||||
id, content=form_data.content
|
id, content=form_data.content
|
||||||
)
|
)
|
||||||
form_data.content = replace_imports(form_data.content)
|
|
||||||
form_data.meta.manifest = frontmatter
|
form_data.meta.manifest = frontmatter
|
||||||
|
|
||||||
TOOLS = request.app.state.TOOLS
|
TOOLS = request.app.state.TOOLS
|
||||||
|
@ -114,7 +114,6 @@ def load_function_module_by_id(function_id, content=None):
|
|||||||
raise Exception(f"Function not found: {function_id}")
|
raise Exception(f"Function not found: {function_id}")
|
||||||
content = function.content
|
content = function.content
|
||||||
|
|
||||||
# Replace the module paths in the function content
|
|
||||||
content = replace_imports(content)
|
content = replace_imports(content)
|
||||||
Functions.update_function_by_id(function_id, {"content": content})
|
Functions.update_function_by_id(function_id, {"content": content})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user