Salt
commited on
Commit
·
73b878e
1
Parent(s):
38392fe
Update server.py
Browse files
server.py
CHANGED
@@ -1,12 +1,16 @@
|
|
|
|
1 |
from flask import (
|
2 |
Flask,
|
3 |
jsonify,
|
4 |
request,
|
5 |
render_template_string,
|
6 |
abort,
|
|
|
|
|
7 |
)
|
8 |
from flask_cors import CORS
|
9 |
import unicodedata
|
|
|
10 |
import markdown
|
11 |
import time
|
12 |
import os
|
@@ -33,11 +37,30 @@ colorama_init()
|
|
33 |
port = 7860
|
34 |
host = "0.0.0.0"
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
summarization_model = (
|
37 |
-
|
|
|
|
|
38 |
)
|
39 |
classification_model = (
|
40 |
-
|
|
|
|
|
41 |
)
|
42 |
|
43 |
|
|
|
1 |
+
from functools import wraps
|
2 |
from flask import (
|
3 |
Flask,
|
4 |
jsonify,
|
5 |
request,
|
6 |
render_template_string,
|
7 |
abort,
|
8 |
+
send_from_directory,
|
9 |
+
send_file,
|
10 |
)
|
11 |
from flask_cors import CORS
|
12 |
import unicodedata
|
13 |
+
import argparse
|
14 |
import markdown
|
15 |
import time
|
16 |
import os
|
|
|
37 |
port = 7860
|
38 |
host = "0.0.0.0"
|
39 |
|
40 |
+
|
41 |
+
|
42 |
+
class SplitArgs(argparse.Action):
|
43 |
+
def __call__(self, parser, namespace, values, option_string=None):
|
44 |
+
setattr(
|
45 |
+
namespace, self.dest, values.replace('"', "").replace("'", "").split(",")
|
46 |
+
)
|
47 |
+
parser = argparse.ArgumentParser(
|
48 |
+
prog="TavernAI Extras", description="Web API for transformers models"
|
49 |
+
)
|
50 |
+
parser.add_argument("--summarization-model", help="Load a custom summarization model")
|
51 |
+
parser.add_argument("--classification-model", help="Load a custom text classification model")
|
52 |
+
|
53 |
+
args = parser.parse_args()
|
54 |
+
|
55 |
summarization_model = (
|
56 |
+
args.summarization_model
|
57 |
+
if args.summarization_model
|
58 |
+
else DEFAULT_SUMMARIZATION_MODEL
|
59 |
)
|
60 |
classification_model = (
|
61 |
+
args.classification_model
|
62 |
+
if args.classification_model
|
63 |
+
else DEFAULT_CLASSIFICATION_MODEL
|
64 |
)
|
65 |
|
66 |
|