yetessam commited on
Commit
30a38c2
·
verified ·
1 Parent(s): 3d41af7

Update tools/polite_guard.py

Browse files
Files changed (1) hide show
  1. tools/polite_guard.py +7 -4
tools/polite_guard.py CHANGED
@@ -43,10 +43,13 @@ class PoliteGuardTool(Tool):
43
  """
44
  try:
45
  classifier = pipeline("text-classification", "Intel/polite-guard")
46
- result = classifier(input_text)[0]
47
- print(result)
48
- print(len(result))
49
- return result['label'], result['score']
 
 
 
50
 
51
  except Exception as e:
52
  return f"Error fetching classification for text '{input_text}': {str(e)}"
 
43
  """
44
  try:
45
  classifier = pipeline("text-classification", "Intel/polite-guard")
46
+ result = classifier(input_text)
47
+ print(f"return {str(result)}")
48
+ print(f"length is {len(result)}")
49
+ # get the first tuple
50
+ label = result[0]['label']
51
+ score = result[0]['score']
52
+ return label, score
53
 
54
  except Exception as e:
55
  return f"Error fetching classification for text '{input_text}': {str(e)}"