Spaces:
Running
Running
Update tools/polite_guard.py
Browse files- tools/polite_guard.py +14 -14
tools/polite_guard.py
CHANGED
@@ -33,17 +33,17 @@ class PoliteGuardTool(Tool):
|
|
33 |
|
34 |
#@tool
|
35 |
def ask_polite_guard(self, input_text: str) -> tuple[str,int]:
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
33 |
|
34 |
#@tool
|
35 |
def ask_polite_guard(self, input_text: str) -> tuple[str,int]:
|
36 |
+
"""
|
37 |
+
|
38 |
+
Args:
|
39 |
+
input_text: The text to classify.
|
40 |
+
|
41 |
+
Returns:
|
42 |
+
tuple: with classification label and the score
|
43 |
+
"""
|
44 |
+
try:
|
45 |
+
classifier = pipeline("text-classification", "Intel/polite-guard")
|
46 |
+
return classifier(input_text)
|
47 |
+
|
48 |
+
except Exception as e:
|
49 |
+
return f"Error fetching classification for text '{input_text}': {str(e)}"
|