now works in offline too

This commit is contained in:
Saifeddine ALOUI 2024-08-02 09:46:55 +02:00
parent 921ddbb3f7
commit 2cf63c5b78

View File

@ -16,7 +16,7 @@ import subprocess
import yaml import yaml
import uuid import uuid
import platform import platform
from ascii_colors import ASCIIColors, trace_exception
router = APIRouter() router = APIRouter()
lollmsElfServer: LOLLMSWebUI = LOLLMSWebUI.get_instance() lollmsElfServer: LOLLMSWebUI = LOLLMSWebUI.get_instance()
@ -40,9 +40,9 @@ class AppInfo:
@router.get("/apps") @router.get("/apps")
async def list_apps(): async def list_apps():
apps = [] apps = []
binding_models_path = lollmsElfServer.lollms_paths.apps_zoo_path apps_zoo_path = lollmsElfServer.lollms_paths.apps_zoo_path
for app_name in binding_models_path.iterdir(): for app_name in apps_zoo_path.iterdir():
if app_name.is_dir(): if app_name.is_dir():
icon_path = app_name / "icon.png" icon_path = app_name / "icon.png"
description_path = app_name / "description.yaml" description_path = app_name / "description.yaml"
@ -264,10 +264,11 @@ async def fetch_github_apps():
try: try:
clone_repo() clone_repo()
pull_repo() pull_repo()
apps = load_apps_data() except:
return {"apps": apps} ASCIIColors.error("Couldn't interact with ")
except Exception as e: lollmsElfServer.error("Couldn't interact with github.\nPlease verify your internet connection")
raise HTTPException(status_code=500, detail=str(e)) apps = load_apps_data()
return {"apps": apps}
@router.get("/apps/{app_name}/icon") @router.get("/apps/{app_name}/icon")
async def get_app_icon(app_name: str): async def get_app_icon(app_name: str):