Made the frontend more flexible to also support other models than just Koala
This commit is contained in:
parent
02a142012b
commit
c3fda61b21
4 changed files with 71 additions and 48 deletions
|
@ -2,18 +2,40 @@
|
|||
# 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("/")}
|
||||
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)
|
||||
|
|
Reference in a new issue