yetessam commited on
Commit
5c18de9
·
verified ·
1 Parent(s): 5e2a133

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py CHANGED
@@ -11,6 +11,21 @@ from Gradio_UI import GradioUI
11
 
12
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  @tool
15
  def get_current_time_in_timezone(timezone: str) -> str:
16
  """A tool that fetches the current local time in a specified timezone.
 
11
 
12
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
13
 
14
+
15
+ # Tool to classify text into politeness categories
16
+ @tool
17
+ def ask_polite_guard(input_text: str) -> str:
18
+ """Tool that classifies text into four categories: polite, somewhat polite, neutral, and impolite.
19
+
20
+ Args:
21
+ input_text: The text to classify.
22
+ """
23
+ try:
24
+ classifier = pipeline("text-classification", "Intel/polite-guard")
25
+ return classifier(input_text)
26
+ except Exception as e:
27
+ return f"Error fetching classification for text '{input_text}': {str(e)}"
28
+
29
  @tool
30
  def get_current_time_in_timezone(timezone: str) -> str:
31
  """A tool that fetches the current local time in a specified timezone.