yetessam commited on
Commit
2f54f8b
·
verified ·
1 Parent(s): 69374ab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -14,7 +14,7 @@ from Gradio_UI import GradioUI
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:
@@ -22,7 +22,11 @@ def ask_polite_guard(input_text: str) -> str:
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
 
 
14
 
15
  # Tool to classify text into politeness categories
16
  @tool
17
+ def ask_polite_guard(input_text: str) -> dict:
18
  """Tool that classifies text into four categories: polite, somewhat polite, neutral, and impolite.
19
 
20
  Args:
 
22
  """
23
  try:
24
  classifier = pipeline("text-classification", "Intel/polite-guard")
25
+ return {
26
+ "label": result['label'],
27
+ "score": result['score']
28
+ }
29
+
30
  except Exception as e:
31
  return f"Error fetching classification for text '{input_text}': {str(e)}"
32