Skip to content

Commit

Permalink
Update refusal_shield.py
Browse files Browse the repository at this point in the history
  • Loading branch information
shlomsh committed Dec 17, 2023
1 parent b725e84 commit 13480ab
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from typing import List
from typing import List, Optional
from uuid import UUID
import math
from transformers import pipeline
Expand All @@ -8,9 +8,9 @@


class RefusalShieldDeflectionResult(ShieldDeflectionResult):
model: str = ""
labels: List
scores: List
model: Optional[str] = None
labels: Optional[List] = None
scores: Optional[List] = None


class RefusalShield(VibraniumShield):
Expand Down Expand Up @@ -50,6 +50,6 @@ def deflect(self, llm_interaction: LLMInteraction, shield_policy_config: dict, s
if risk >= threshold:
shield_results.append(RefusalShieldDeflectionResult(model=self._model, labels=categories, scores=[risk, round(1 - risk, 2)], risk=risk))
else:
shield_results.append(RefusalShieldDeflectionResult(model=self._model, labels=categories, scores=[risk, round(1 - risk, 2)], risk=0))
shield_results.append(RefusalShieldDeflectionResult())

return shield_results

0 comments on commit 13480ab

Please sign in to comment.