mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2024-12-19 04:17:52 +00:00
49 lines
1.5 KiB
Python
49 lines
1.5 KiB
Python
"""
|
|
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)
|
|
from endpoints.lollms_infos import *
|
|
|
|
uvicorn.run(app, host=config.host, port=config.port) |