MCPcopy Index your code
hub / github.com/microsoft/PyRIT / get_value

Method get_value

pyrit/models/score.py:131–151  ·  view source on GitHub ↗

Return the value of the score based on its type. If the score type is "true_false", it returns True if the score value is "true" (case-insensitive), otherwise it returns False. If the score type is "float_scale", it returns the score value as a float. Retu

(self)

Source from the content-addressed store, hash-verified

129 # Public API
130 # ------------------------------------------------------------------ #
131 def get_value(self) -> bool | float:
132 """
133 Return the value of the score based on its type.
134
135 If the score type is "true_false", it returns True if the score value is "true" (case-insensitive),
136 otherwise it returns False.
137
138 If the score type is "float_scale", it returns the score value as a float.
139
140 Returns:
141 bool | float: Parsed score value.
142
143 Raises:
144 ValueError: If the score type is unknown.
145 """
146 if self.score_type == "true_false":
147 return self.score_value.lower() == "true"
148 if self.score_type == "float_scale":
149 return float(self.score_value)
150
151 raise ValueError(f"Unknown scorer type: {self.score_type}")
152
153 def __str__(self) -> str:
154 """

Callers 15

_render_scoreMethod · 0.45
_format_scoreMethod · 0.45
normalize_score_to_floatFunction · 0.45
aggregatorFunction · 0.45
_score_asyncMethod · 0.45
_score_piece_asyncMethod · 0.45
aggregatorFunction · 0.45

Calls

no outgoing calls