app.py
CHANGED
|
@@ -12,4 +12,9 @@ def greet_json():
|
|
| 12 |
"This is a course about the Transformers library",
|
| 13 |
candidate_labels=["education", "politics", "business"],
|
| 14 |
)
|
| 15 |
-
return {"Hello": str(j)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
"This is a course about the Transformers library",
|
| 13 |
candidate_labels=["education", "politics", "business"],
|
| 14 |
)
|
| 15 |
+
return {"Hello": str(j)}
|
| 16 |
+
|
| 17 |
+
@app.post('/zero-shot-classification')
|
| 18 |
+
def classify(source: str, labels: list[str]) -> dict[str, str]:
|
| 19 |
+
c = classifier(source, candidate_labels = labels)
|
| 20 |
+
return dict(zip(c['labels'], c['scores']))
|