in pyrit/ui/rpc.py [0:0]
def wait_for_score(self) -> Score:
"""
Wait for the client to send a score. Should always return a score, but if the synchronisation fails it will
return None.
"""
if self._score_received_semaphore is None or self._rpc_service is None:
raise RPCAppException("RPC server is not running.")
self._score_received_semaphore.acquire()
if not self._server_is_running:
raise RPCServerStoppedException()
score_ref = self._rpc_service.pop_score_received()
self._client_ready_semaphore.release()
if score_ref is None:
return None
# Pass instance variables of reflected RPyC Score object as args to PyRIT Score object
score = Score(
score_value=score_ref.score_value,
score_type=score_ref.score_type,
score_category=str(score_ref.score_category),
score_value_description=score_ref.score_value_description,
score_rationale=score_ref.score_rationale,
score_metadata=score_ref.score_metadata,
prompt_request_response_id=score_ref.prompt_request_response_id,
)
return score