Spaces:
Sleeping
Sleeping
Update tools/polite_guard.py
Browse files- tools/polite_guard.py +6 -2
tools/polite_guard.py
CHANGED
|
@@ -31,7 +31,7 @@ class PoliteGuardTool(Tool):
|
|
| 31 |
self.label = None
|
| 32 |
self.score = None
|
| 33 |
|
| 34 |
-
def ask_polite_guard(self, input_text: str) ->
|
| 35 |
"""
|
| 36 |
|
| 37 |
Args:
|
|
@@ -45,7 +45,11 @@ class PoliteGuardTool(Tool):
|
|
| 45 |
result = classifier(input_text)
|
| 46 |
print(f"return {str(result)}")
|
| 47 |
output = result[0]
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
except Exception as e:
|
| 51 |
return f"Error fetching classification for text '{input_text}': {str(e)}"
|
|
|
|
| 31 |
self.label = None
|
| 32 |
self.score = None
|
| 33 |
|
| 34 |
+
def ask_polite_guard(self, input_text: str) -> str:
|
| 35 |
"""
|
| 36 |
|
| 37 |
Args:
|
|
|
|
| 45 |
result = classifier(input_text)
|
| 46 |
print(f"return {str(result)}")
|
| 47 |
output = result[0]
|
| 48 |
+
|
| 49 |
+
label = output['label']
|
| 50 |
+
score = output['score']
|
| 51 |
+
str_output = f"label is {label} with a score of {score}"
|
| 52 |
+
return str_output
|
| 53 |
|
| 54 |
except Exception as e:
|
| 55 |
return f"Error fetching classification for text '{input_text}': {str(e)}"
|