This commit is contained in:
Saifeddine ALOUI 2024-03-31 21:18:20 +02:00
parent b0967d419b
commit d14103c1cf
2 changed files with 10 additions and 3 deletions

View File

@ -43,7 +43,6 @@ def sanitize_path(path:str, allow_absolute_path:bool=False, error_text="Absolute
if path is None: if path is None:
return path return path
# Regular expression to detect patterns like "...." and multiple forward slashes # Regular expression to detect patterns like "...." and multiple forward slashes
suspicious_patterns = re.compile(r'(\.\.+)|(/+/)') suspicious_patterns = re.compile(r'(\.\.+)|(/+/)')

View File

@ -250,6 +250,8 @@ class PersonalityDataRequest(BaseModel):
category:str category:str
name:str name:str
@router.post("/get_personality_config") @router.post("/get_personality_config")
def get_personality_config(data:PersonalityDataRequest): def get_personality_config(data:PersonalityDataRequest):
print("- Recovering personality config") print("- Recovering personality config")
@ -459,8 +461,12 @@ def unmount_personality(data:PersonalityMountingInfos):
return {"status": False, "error":"Couldn't unmount personality"} return {"status": False, "error":"Couldn't unmount personality"}
@router.get("/unmount_all_personalities") class AuthenticationInfos(BaseModel):
def unmount_all_personalities(): client_id:str
@router.post("/unmount_all_personalities")
def unmount_all_personalities(data:AuthenticationInfos):
check_access(lollmsElfServer, data.client_id)
lollmsElfServer.config.personalities=["generic/lollms"] lollmsElfServer.config.personalities=["generic/lollms"]
lollmsElfServer.mounted_personalities=[] lollmsElfServer.mounted_personalities=[]
lollmsElfServer.personality=None lollmsElfServer.personality=None
@ -474,6 +480,7 @@ def unmount_all_personalities():
@router.post("/select_personality") @router.post("/select_personality")
def select_personality(data:PersonalitySelectionInfos): def select_personality(data:PersonalitySelectionInfos):
check_access(lollmsElfServer, data.client_id)
ASCIIColors.info("Selecting personality") ASCIIColors.info("Selecting personality")
id = data.id id = data.id
print(f"- Selecting active personality {id} ...",end="") print(f"- Selecting active personality {id} ...",end="")
@ -502,6 +509,7 @@ def select_personality(data:PersonalitySelectionInfos):
@router.post("/get_personality_settings") @router.post("/get_personality_settings")
def get_personality_settings(data:PersonalityMountingInfos): def get_personality_settings(data:PersonalityMountingInfos):
check_access(lollmsElfServer, data.client_id)
print("- Retreiving personality settings") print("- Retreiving personality settings")
category = sanitize_path(data.category) category = sanitize_path(data.category)
name = sanitize_path(data.folder) name = sanitize_path(data.folder)