-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.py
62 lines (53 loc) · 1.94 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from datetime import datetime
import logging
import os
from argparse import ArgumentParser
from webapp import create_app, socketio
app = create_app()
os.makedirs("logs", exist_ok=True)
log_file_name = datetime.now().strftime(
os.path.join("logs", "llmanonymizer_%H_%M_%d_%m_%Y.log")
)
logging.basicConfig(
level=logging.DEBUG,
filename=log_file_name,
filemode="w",
format="%(asctime)s - %(levelname)s - %(message)s",
)
logging.debug("Start LLM Anonymizer")
if __name__ == "__main__":
parser = ArgumentParser(description="Parameters to run the KatherLab LLM Pipeline")
parser.add_argument(
"--model_path",
type=str,
default=r"path\to\models",
help="Path where the models are stored which llama cpp can load.",
)
parser.add_argument(
"--server_path",
type=str,
default=r"path\to\server.exe",
)
parser.add_argument(
"--port",
type=int,
default=5001,
help="On which port the Web App should be available.",
)
parser.add_argument("--host", type=str, default="0.0.0.0")
parser.add_argument("--config_file", type=str, default="config.yml")
parser.add_argument("--n_gpu_layers", type=int, default=80)
parser.add_argument("--n_predict", type=int, default=384)
parser.add_argument("--llamacpp_port", type=int, default=2929)
parser.add_argument("--debug", action="store_true")
args = parser.parse_args()
app.config["MODEL_PATH"] = args.model_path
app.config["SERVER_PATH"] = args.server_path
app.config["SERVER_PORT"] = args.port
app.config["CONFIG_FILE"] = args.config_file
app.config["N_GPU_LAYERS"] = args.n_gpu_layers
app.config["N_PREDICT"] = args.n_predict
app.config["LLAMACPP_PORT"] = args.llamacpp_port
app.config["DEBUG"] = args.debug
print("Start Server on http://" + args.host + ":" + str(args.port))
socketio.run(app, debug=args.debug, use_reloader=args.debug, port=args.port)