Spaces:
Running
Running
Update tools/polite_guard.py
Browse files- tools/polite_guard.py +7 -4
tools/polite_guard.py
CHANGED
@@ -43,10 +43,13 @@ class PoliteGuardTool(Tool):
|
|
43 |
"""
|
44 |
try:
|
45 |
classifier = pipeline("text-classification", "Intel/polite-guard")
|
46 |
-
result = classifier(input_text)
|
47 |
-
print(result)
|
48 |
-
print(len(result))
|
49 |
-
|
|
|
|
|
|
|
50 |
|
51 |
except Exception as e:
|
52 |
return f"Error fetching classification for text '{input_text}': {str(e)}"
|
|
|
43 |
"""
|
44 |
try:
|
45 |
classifier = pipeline("text-classification", "Intel/polite-guard")
|
46 |
+
result = classifier(input_text)
|
47 |
+
print(f"return {str(result)}")
|
48 |
+
print(f"length is {len(result)}")
|
49 |
+
# get the first tuple
|
50 |
+
label = result[0]['label']
|
51 |
+
score = result[0]['score']
|
52 |
+
return label, score
|
53 |
|
54 |
except Exception as e:
|
55 |
return f"Error fetching classification for text '{input_text}': {str(e)}"
|