Spaces:
Running
Running
liujch1998
commited on
Commit
Β·
16902fa
1
Parent(s):
50d13b1
Bug fix
Browse files- app.py +3 -3
- constants.py +1 -1
app.py
CHANGED
@@ -18,7 +18,7 @@ def process(query_type, index_desc, **kwargs):
|
|
18 |
if API_URL is None:
|
19 |
raise ValueError(f'API_URL envvar is not set!')
|
20 |
try:
|
21 |
-
response = requests.post(API_URL, json=data, timeout=
|
22 |
except requests.exceptions.Timeout:
|
23 |
raise ValueError('Web request timed out. Please try again later.')
|
24 |
except requests.exceptions.RequestException as e:
|
@@ -61,10 +61,10 @@ def creativity(index_desc, query):
|
|
61 |
htmls = []
|
62 |
for n in range(NGRAM_LEN_MIN, NGRAM_LEN_MAX + 1):
|
63 |
html = ''
|
64 |
-
|
65 |
line_len = 0
|
66 |
for i, (token, highlighted) in enumerate(zip(tokens, highlighteds)):
|
67 |
-
if line_len >=
|
68 |
html += '<br/>'
|
69 |
line_len = 0
|
70 |
color = '0, 0, 255, 0.5'
|
|
|
18 |
if API_URL is None:
|
19 |
raise ValueError(f'API_URL envvar is not set!')
|
20 |
try:
|
21 |
+
response = requests.post(API_URL, json=data, timeout=30)
|
22 |
except requests.exceptions.Timeout:
|
23 |
raise ValueError('Web request timed out. Please try again later.')
|
24 |
except requests.exceptions.RequestException as e:
|
|
|
61 |
htmls = []
|
62 |
for n in range(NGRAM_LEN_MIN, NGRAM_LEN_MAX + 1):
|
63 |
html = ''
|
64 |
+
highlighteds = highlighteds_by_n[n]
|
65 |
line_len = 0
|
66 |
for i, (token, highlighted) in enumerate(zip(tokens, highlighteds)):
|
67 |
+
if line_len >= MAX_DISP_CHARS_PER_LINE and token.startswith('β'):
|
68 |
html += '<br/>'
|
69 |
line_len = 0
|
70 |
color = '0, 0, 255, 0.5'
|
constants.py
CHANGED
@@ -12,9 +12,9 @@ INDEX_DESCS = list(INDEX_BY_DESC.keys())
|
|
12 |
|
13 |
# API limits and defaults
|
14 |
MAX_QUERY_CHARS = int(os.environ.get('MAX_QUERY_CHARS', 1000))
|
15 |
-
NGRAM_LEN_DEFAULT = int(os.environ.get('NGRAM_LEN_DEFAULT', 8))
|
16 |
NGRAM_LEN_MIN = int(os.environ.get('NGRAM_LEN_MIN', 5))
|
17 |
NGRAM_LEN_MAX = int(os.environ.get('NGRAM_LEN_MAX', 11))
|
|
|
18 |
|
19 |
# HF demo
|
20 |
API_URL = os.environ.get('API_URL', None)
|
|
|
12 |
|
13 |
# API limits and defaults
|
14 |
MAX_QUERY_CHARS = int(os.environ.get('MAX_QUERY_CHARS', 1000))
|
|
|
15 |
NGRAM_LEN_MIN = int(os.environ.get('NGRAM_LEN_MIN', 5))
|
16 |
NGRAM_LEN_MAX = int(os.environ.get('NGRAM_LEN_MAX', 11))
|
17 |
+
MAX_DISP_CHARS_PER_LINE = int(os.environ.get('MAX_DISP_CHARS_PER_LINE', 100))
|
18 |
|
19 |
# HF demo
|
20 |
API_URL = os.environ.get('API_URL', None)
|