#!/usr/bin/env python3 # Copyright (c) 2023 Julian Müller (ChaoticByte) from argparse import ArgumentParser from json import load from pathlib import Path import uvicorn from frontend.app import app if __name__ == "__main__": koala_profile_path = Path(__file__).parent / "profiles" / "koala.json" # CLI ap = ArgumentParser() ap.add_argument("--profile", help="Path to a profile file that includes settings for a specific model (default: ./profiles/koala.json)", type=Path, default=koala_profile_path) ap.add_argument("--host", help="Address to listen on (default: localhost)", type=str, default="localhost") ap.add_argument("--port", help="Port to listen on (default: 8080)", type=int, default=8080) ap.add_argument("--api", help="URL of the API Server (default: 'http://localhost:7331')", type=str, default="http://localhost:7331") args = ap.parse_args() # Read profile with args.profile.open("r") as pf: profile = load(pf) # Check profile assert "name" in profile assert "conversation_prefix" in profile assert "user_keyword" in profile assert "assistant_keyword" in profile assert "stop_sequence" in profile # Pass frontend config to the app app.config.frontend_config = { "api_url": args.api.rstrip("/"), "profile": { "name": profile["name"], "conversation_prefix": profile["conversation_prefix"], "user_keyword": profile["user_keyword"], "assistant_keyword": profile["assistant_keyword"], "stop_sequence": profile["stop_sequence"] } } # Run uvicorn.run(app, host=args.host, port=args.port)