mirror of
https://github.com/ParisNeo/lollms.git
synced 2025-01-20 03:36:30 +00:00
Added more endpoints to the fastapi
This commit is contained in:
parent
adf1e23559
commit
4ef9f5d72c
@ -214,12 +214,14 @@ class LoLLMsServer(LollmsApplication):
|
||||
|
||||
self.binding = None
|
||||
for per in self.mounted_personalities:
|
||||
per.model = None
|
||||
if per is not None:
|
||||
per.model = None
|
||||
gc.collect()
|
||||
self.binding = BindingBuilder().build_binding(self.config, self.lollms_paths, lollmsCom=self)
|
||||
self.model = self.binding.build_model()
|
||||
for per in self.mounted_personalities:
|
||||
per.model = self.model
|
||||
if per is not None:
|
||||
per.model = self.model
|
||||
except Exception as ex:
|
||||
# Catch the exception and get the traceback as a list of strings
|
||||
traceback_lines = traceback.format_exception(type(ex), ex, ex.__traceback__)
|
||||
|
@ -84,7 +84,8 @@ def reload_binding( params: ReloadBindingParams):
|
||||
lollmsElfServer.binding = None
|
||||
lollmsElfServer.model = None
|
||||
for per in lollmsElfServer.mounted_personalities:
|
||||
per.model = None
|
||||
if per is not None:
|
||||
per.model = None
|
||||
gc.collect()
|
||||
lollmsElfServer.binding = BindingBuilder().build_binding(lollmsElfServer.config, lollmsElfServer.lollms_paths, InstallOption.INSTALL_IF_NECESSARY, lollmsCom=lollmsElfServer)
|
||||
lollmsElfServer.model = None
|
||||
@ -125,7 +126,8 @@ def install_binding(data:BindingInstallParams):
|
||||
lollmsElfServer.binding = BindingBuilder().build_binding(lollmsElfServer.config, lollmsElfServer.lollms_paths, lollmsCom=lollmsElfServer)
|
||||
lollmsElfServer.model = lollmsElfServer.binding.build_model()
|
||||
for per in lollmsElfServer.mounted_personalities:
|
||||
per.model = lollmsElfServer.model
|
||||
if per is not None:
|
||||
per.model = lollmsElfServer.model
|
||||
return {"status": True}
|
||||
except Exception as ex:
|
||||
lollmsElfServer.error(f"Couldn't build binding: [{ex}]")
|
||||
@ -159,7 +161,8 @@ def reinstall_binding(data:BindingInstallParams):
|
||||
lollmsElfServer.binding = BindingBuilder().build_binding(lollmsElfServer.config, lollmsElfServer.lollms_paths, lollmsCom=lollmsElfServer)
|
||||
lollmsElfServer.model = lollmsElfServer.binding.build_model()
|
||||
for per in lollmsElfServer.mounted_personalities:
|
||||
per.model = lollmsElfServer.model
|
||||
if per is not None:
|
||||
per.model = lollmsElfServer.model
|
||||
|
||||
return {"status": True}
|
||||
except Exception as ex:
|
||||
@ -196,7 +199,8 @@ def unInstall_binding(data:BindingInstallParams):
|
||||
lollmsElfServer.binding = BindingBuilder().build_binding(lollmsElfServer.config, lollmsElfServer.lollms_paths, lollmsCom=lollmsElfServer)
|
||||
lollmsElfServer.model = lollmsElfServer.binding.build_model()
|
||||
for per in lollmsElfServer.mounted_personalities:
|
||||
per.model = lollmsElfServer.model
|
||||
if per is not None:
|
||||
per.model = lollmsElfServer.model
|
||||
else:
|
||||
lollmsElfServer.config.binding_name = None
|
||||
if lollmsElfServer.config.auto_save:
|
||||
|
@ -80,7 +80,8 @@ def update_setting(data:SettingsInfos):
|
||||
lollmsElfServer.binding = None
|
||||
lollmsElfServer.model = None
|
||||
for per in lollmsElfServer.mounted_personalities:
|
||||
per.model = None
|
||||
if per is not None:
|
||||
per.model = None
|
||||
gc.collect()
|
||||
lollmsElfServer.binding = BindingBuilder().build_binding(lollmsElfServer.config, lollmsElfServer.lollms_paths, InstallOption.INSTALL_IF_NECESSARY, lollmsCom=lollmsElfServer)
|
||||
lollmsElfServer.model = None
|
||||
@ -109,7 +110,8 @@ def update_setting(data:SettingsInfos):
|
||||
if lollmsElfServer.model is not None:
|
||||
ASCIIColors.yellow("New model OK")
|
||||
for per in lollmsElfServer.mounted_personalities:
|
||||
per.model = lollmsElfServer.model
|
||||
if per is not None:
|
||||
per.model = lollmsElfServer.model
|
||||
except Exception as ex:
|
||||
trace_exception(ex)
|
||||
lollmsElfServer.InfoMessage(f"It looks like you we couldn't load the model.\nHere is the error message:\n{ex}")
|
||||
|
@ -81,6 +81,14 @@ class V1InstructGenerateRequest(BaseModel):
|
||||
router = APIRouter()
|
||||
elf_server = LOLLMSElfServer.get_instance()
|
||||
|
||||
|
||||
|
||||
@router.get("/get_generation_status")
|
||||
def get_generation_status():
|
||||
return {"status":elf_server.busy}
|
||||
|
||||
|
||||
|
||||
@router.post("/generate")
|
||||
def lollms_generate(request_data: GenerateRequest):
|
||||
"""
|
||||
|
@ -168,6 +168,20 @@ def list_mounted_personalities(lollmsElfServer):
|
||||
|
||||
|
||||
|
||||
|
||||
@router.get("/get_current_personality_path_infos")
|
||||
def get_current_personality_path_infos():
|
||||
if lollmsElfServer.personality is None:
|
||||
return {
|
||||
"personality_category":"",
|
||||
"personality_name":""
|
||||
}
|
||||
else:
|
||||
return {
|
||||
"personality_category":lollmsElfServer.personality_category,
|
||||
"personality_name":lollmsElfServer.personality_name
|
||||
}
|
||||
|
||||
# ----------------------------------- Installation/Uninstallation/Reinstallation ----------------------------------------
|
||||
|
||||
|
||||
|
@ -42,11 +42,9 @@ def run_async(func):
|
||||
"""
|
||||
|
||||
async def wrapper(*args, **kwargs):
|
||||
return await func(*args, **kwargs)
|
||||
return asyncio.run(func(*args, **kwargs))
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(wrapper())
|
||||
|
||||
return wrapper()
|
||||
|
||||
def terminate_thread(thread):
|
||||
if thread:
|
||||
|
Loading…
Reference in New Issue
Block a user