mirror of
https://github.com/open-webui/open-webui
synced 2025-03-20 20:08:52 +00:00
fix: functions
This commit is contained in:
parent
647aa1966f
commit
44a9b86eec
@ -107,7 +107,7 @@ class FunctionsTable:
|
|||||||
Session.commit()
|
Session.commit()
|
||||||
Session.refresh(result)
|
Session.refresh(result)
|
||||||
if result:
|
if result:
|
||||||
return FunctionModel.model_validate(result)
|
return FunctionModel(**result.model_dump())
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -117,20 +117,19 @@ class FunctionsTable:
|
|||||||
def get_function_by_id(self, id: str) -> Optional[FunctionModel]:
|
def get_function_by_id(self, id: str) -> Optional[FunctionModel]:
|
||||||
try:
|
try:
|
||||||
function = Session.get(Function, id)
|
function = Session.get(Function, id)
|
||||||
return FunctionModel.model_validate(function)
|
return FunctionModel(**function)
|
||||||
except:
|
except:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_functions(self, active_only=False) -> List[FunctionModel]:
|
def get_functions(self, active_only=False) -> List[FunctionModel]:
|
||||||
if active_only:
|
if active_only:
|
||||||
return [
|
return [
|
||||||
FunctionModel.model_validate(function)
|
FunctionModel(**function)
|
||||||
for function in Session.query(Function).filter_by(is_active=True).all()
|
for function in Session.query(Function).filter_by(is_active=True).all()
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
return [
|
return [
|
||||||
FunctionModel.model_validate(function)
|
FunctionModel(**function) for function in Session.query(Function).all()
|
||||||
for function in Session.query(Function).all()
|
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_functions_by_type(
|
def get_functions_by_type(
|
||||||
@ -138,25 +137,23 @@ class FunctionsTable:
|
|||||||
) -> List[FunctionModel]:
|
) -> List[FunctionModel]:
|
||||||
if active_only:
|
if active_only:
|
||||||
return [
|
return [
|
||||||
FunctionModel.model_validate(function)
|
FunctionModel(**function)
|
||||||
for function in Session.query(Function)
|
for function in Session.query(Function)
|
||||||
.filter_by(type=type, is_active=True)
|
.filter_by(type=type, is_active=True)
|
||||||
.all()
|
.all()
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
return [
|
return [
|
||||||
FunctionModel.model_validate(function)
|
FunctionModel(**function)
|
||||||
for function in Session.query(Function).filter_by(type=type).all()
|
for function in Session.query(Function).filter_by(type=type).all()
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_global_filter_functions(self) -> List[FunctionModel]:
|
def get_global_filter_functions(self) -> List[FunctionModel]:
|
||||||
return [
|
return [
|
||||||
FunctionModel(**model_to_dict(function))
|
FunctionModel(**function)
|
||||||
for function in Function.select().where(
|
for function in Session.query(Function)
|
||||||
Function.type == "filter",
|
.filter_by(type="filter", is_active=True, is_global=True)
|
||||||
Function.is_active == True,
|
.all()
|
||||||
Function.is_global == True,
|
|
||||||
)
|
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_function_valves_by_id(self, id: str) -> Optional[dict]:
|
def get_function_valves_by_id(self, id: str) -> Optional[dict]:
|
||||||
|
Loading…
Reference in New Issue
Block a user