Update app.py
Browse filesAPI payload seems to be dumped as JSON, so let's try to recover it.
app.py
CHANGED
@@ -11,6 +11,14 @@ clf = wbgtopic.WBGDocTopic()
|
|
11 |
|
12 |
@spaces.GPU(enable_queue=True, duration=50)
|
13 |
def fn(inputs):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
return clf.suggest_topics(inputs)
|
15 |
|
16 |
|
|
|
11 |
|
12 |
@spaces.GPU(enable_queue=True, duration=50)
|
13 |
def fn(inputs):
|
14 |
+
if isinstance(inputs, str):
|
15 |
+
# API payload seems to be dumped as JSON, so let's try to recover it.
|
16 |
+
try:
|
17 |
+
inputs = json.loads(inputs)
|
18 |
+
assert isinstance(inputs, list) and isinstance(inputs[0], str)
|
19 |
+
except Exception:
|
20 |
+
pass
|
21 |
+
|
22 |
return clf.suggest_topics(inputs)
|
23 |
|
24 |
|