2024-01-01 03:18:49 +00:00
|
|
|
"""
|
|
|
|
File: lollms_web_ui.py
|
|
|
|
Author: ParisNeo
|
|
|
|
Description: Singleton class for the LoLLMS web UI.
|
|
|
|
|
|
|
|
This file is the entry point to the webui.
|
|
|
|
"""
|
|
|
|
|
|
|
|
from fastapi import FastAPI
|
|
|
|
from fastapi.staticfiles import StaticFiles
|
|
|
|
from lollms.app import LollmsApplication
|
|
|
|
from lollms.paths import LollmsPaths
|
|
|
|
from lollms.main_config import LOLLMSConfig
|
|
|
|
from lollms_webui import LoLLMSWebUI
|
|
|
|
from pathlib import Path
|
|
|
|
from ascii_colors import ASCIIColors
|
|
|
|
import socketio
|
|
|
|
import uvicorn
|
|
|
|
import argparse
|
|
|
|
|
|
|
|
app = FastAPI()
|
|
|
|
sio = socketio.AsyncServer(async_mode="asgi")
|
|
|
|
|
|
|
|
app.mount("/socket.io", socketio.ASGIApp(sio))
|
|
|
|
#app.mount("/socket.io", StaticFiles(directory="path/to/socketio.js"))
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
# Parsong parameters
|
|
|
|
parser = argparse.ArgumentParser(description="Start the chatbot FastAPI app.")
|
|
|
|
|
|
|
|
parser.add_argument(
|
|
|
|
"--host", type=str, default=None, help="the hostname to listen on"
|
|
|
|
)
|
|
|
|
parser.add_argument("--port", type=int, default=None, help="the port to listen on")
|
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
root_path = Path(__file__).parent
|
|
|
|
lollms_paths = LollmsPaths.find_paths(force_local=True, custom_default_cfg_path="configs/config.yaml")
|
|
|
|
config = LOLLMSConfig.autoload(lollms_paths)
|
|
|
|
if args.host:
|
|
|
|
config.host=args.host
|
|
|
|
if args.port:
|
|
|
|
config.port=args.port
|
|
|
|
|
|
|
|
LoLLMSWebUI.build_instance(config=config, lollms_paths=lollms_paths, socketio=sio)
|
2024-01-03 00:41:01 +00:00
|
|
|
from lollms.server.endpoints.lollms_infos import *
|
2024-01-01 03:18:49 +00:00
|
|
|
|
|
|
|
uvicorn.run(app, host=config.host, port=config.port)
|