Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,21 +20,21 @@ def ask_polite_guard(input_text:str)-> str:
|
|
| 20 |
arg2: the second argument
|
| 21 |
"""
|
| 22 |
|
| 23 |
-
try:
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
return classifier(input_text)
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
| 38 |
|
| 39 |
|
| 40 |
@tool
|
|
|
|
| 20 |
arg2: the second argument
|
| 21 |
"""
|
| 22 |
|
| 23 |
+
try:
|
| 24 |
+
|
| 25 |
+
classifier = pipeline("text-classification", "Intel/polite-guard")
|
| 26 |
+
|
| 27 |
+
# result = polite_guard.check_politeness(user_input)
|
| 28 |
+
#if result.is_polite:
|
| 29 |
+
# return "Thank you for your polite message! How can I assist you?"
|
| 30 |
+
#else:
|
| 31 |
+
# return "Please rephrase your message to be more polite."
|
| 32 |
+
|
|
|
|
|
|
|
| 33 |
|
| 34 |
+
return classifier(input_text)
|
| 35 |
+
|
| 36 |
+
except Exception as e:
|
| 37 |
+
return f"Error fetching classification for text '{input_text}': {str(e)}"
|
| 38 |
|
| 39 |
|
| 40 |
@tool
|