Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -30,6 +30,9 @@ def predict_text(params):
|
|
| 30 |
# api = params.get("api", "")
|
| 31 |
# job_id = params.get("job_id", "")
|
| 32 |
|
|
|
|
|
|
|
|
|
|
| 33 |
solutions = []
|
| 34 |
|
| 35 |
for text in texts:
|
|
@@ -55,12 +58,12 @@ def predict_text(params):
|
|
| 55 |
result = {'text': text, 'label': [label[pred_label]]}
|
| 56 |
solutions.append(result)
|
| 57 |
|
| 58 |
-
result_url = f"{api}/{job_id}"
|
| 59 |
-
send_results_to_api(solutions, result_url)
|
| 60 |
-
return json.dumps({"solutions": solutions}
|
| 61 |
|
| 62 |
|
| 63 |
-
inputt = gr.Textbox(label="Parameter in JSON format (e.g., {'texts': ['sample text', 'sample text2']
|
| 64 |
outputt = gr.JSON()
|
| 65 |
|
| 66 |
application = gr.Interface(fn=predict_text, inputs=inputt, outputs=outputt, title="Text Classification with BERT and API Integration")
|
|
|
|
| 30 |
# api = params.get("api", "")
|
| 31 |
# job_id = params.get("job_id", "")
|
| 32 |
|
| 33 |
+
if not texts:
|
| 34 |
+
return { "error": f"Invalid JSON input {e.msg} at line {e.lineno} column {e.colno}"}
|
| 35 |
+
|
| 36 |
solutions = []
|
| 37 |
|
| 38 |
for text in texts:
|
|
|
|
| 58 |
result = {'text': text, 'label': [label[pred_label]]}
|
| 59 |
solutions.append(result)
|
| 60 |
|
| 61 |
+
# result_url = f"{api}/{job_id}"
|
| 62 |
+
# send_results_to_api(solutions, result_url)
|
| 63 |
+
return json.dumps({"solutions": solutions})
|
| 64 |
|
| 65 |
|
| 66 |
+
inputt = gr.Textbox(label="Parameter in JSON format (e.g., {'texts': ['sample text', 'sample text2']'})")
|
| 67 |
outputt = gr.JSON()
|
| 68 |
|
| 69 |
application = gr.Interface(fn=predict_text, inputs=inputt, outputs=outputt, title="Text Classification with BERT and API Integration")
|