yetessam commited on
Commit
243dca5
·
verified ·
1 Parent(s): 8ab9b9f

Update tools/polite_guard.py

Browse files
Files changed (1) hide show
  1. tools/polite_guard.py +4 -3
tools/polite_guard.py CHANGED
@@ -22,7 +22,8 @@ class PoliteGuardTool(Tool):
22
  output_type = "any"
23
 
24
  def forward(self, input_text: Any) -> Any:
25
- self.label = self.ask_polite_guard(input_text)
 
26
  return self.label
27
 
28
  def __init__(self, *args, **kwargs):
@@ -31,14 +32,14 @@ class PoliteGuardTool(Tool):
31
  self.score = None
32
 
33
  #@tool
34
- def ask_polite_guard(self, input_text: str) -> str:
35
  """
36
 
37
  Args:
38
  input_text: The text to classify.
39
 
40
  Returns:
41
- string with classification label
42
  """
43
  try:
44
  classifier = pipeline("text-classification", "Intel/polite-guard")
 
22
  output_type = "any"
23
 
24
  def forward(self, input_text: Any) -> Any:
25
+ self.label, self.score = self.ask_polite_guard(input_text)
26
+ print(f"forward sets the following: {self.label } and {self.score}" )
27
  return self.label
28
 
29
  def __init__(self, *args, **kwargs):
 
32
  self.score = None
33
 
34
  #@tool
35
+ def ask_polite_guard(self, input_text: str) -> tuple[str,int]:
36
  """
37
 
38
  Args:
39
  input_text: The text to classify.
40
 
41
  Returns:
42
+ tuple: with classification label and the score
43
  """
44
  try:
45
  classifier = pipeline("text-classification", "Intel/polite-guard")