Spaces:
Sleeping
Sleeping
fix: string indices must be integers
Browse files- src/api.py +6 -2
src/api.py
CHANGED
|
@@ -210,8 +210,12 @@ async def grade_writing(request: WritingRequest):
|
|
| 210 |
else:
|
| 211 |
final_input = f"{request.prompt} [SEP] {request.essay}"
|
| 212 |
|
| 213 |
-
|
| 214 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 215 |
|
| 216 |
def r(x): return round(x * 2) / 2
|
| 217 |
|
|
|
|
| 210 |
else:
|
| 211 |
final_input = f"{request.prompt} [SEP] {request.essay}"
|
| 212 |
|
| 213 |
+
out = model(final_input, truncation=True, max_length=512)
|
| 214 |
+
|
| 215 |
+
# sometimes out = [[{label,score}...]]; sometimes out = [{label,score}...]
|
| 216 |
+
results = out[0] if (isinstance(out, list) and len(out) and isinstance(out[0], list)) else out
|
| 217 |
+
|
| 218 |
+
raw = {item["label"]: item["score"] for item in results}
|
| 219 |
|
| 220 |
def r(x): return round(x * 2) / 2
|
| 221 |
|