-
Notifications
You must be signed in to change notification settings - Fork 401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MAINT: Refactor Skeleton Key to be a subclass of PromptSendingOrchest… #650
base: main
Are you sure you want to change the base?
Conversation
@microsoft-github-policy-service agree |
@@ -23,11 +23,12 @@ | |||
PromptConverterConfiguration, | |||
) | |||
from pyrit.prompt_target import PromptTarget | |||
from pyrit.orchestrator.single_turn.prompt_sending_orchestrator import PromptSendingOrchestrator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from pyrit.orchestrator.single_turn.prompt_sending_orchestrator import PromptSendingOrchestrator | |
from pyrit.orchestrator.single_turn import PromptSendingOrchestrator |
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class SkeletonKeyOrchestrator(Orchestrator): | ||
class SkeletonKeyOrchestrator(PromptSendingOrchestrator): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommend moving this file to pyrit/orchestrator/single_turn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(and as part of that move, updating init.py
""" | ||
if hasattr(self._prompt_target, 'rpm') and self._prompt_target.rpm and self._batch_size != 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be removed - it's the responsibility of the target to check this
conversation_id = str(uuid4()) | ||
metadata = {"conversation_id": conversation_id} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the conversation_id as metadata. PromptRequestPieces have this as an attribute and it can be set there
|
||
# Return the attack prompt response (second response) | ||
return responses[1] | ||
|
||
def print_conversation(self) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should be able to remove print_conversation and use the parent class
|
||
Returns: | ||
list[PromptRequestResponse]: The responses from the prompt target. | ||
PromptRequestResponse: The response from the prompt target. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of doing it like how it was done, I would make use of PromptSendingOrchestrator.
- Use the
set_prepended_conversation
to set the skeleton key. This can be done in init - You can remove the
send_skeleton_key_with_prompt_async
function. Sending any prompt will then have the skeleton key prepended
prompt_converters=prompt_converters, | ||
batch_size=batch_size, | ||
verbose=verbose | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pre-commit is failing. You can run it using pre-commit run --all-files; And you can see the current issues in the CI build: https://github.com/Azure/PyRIT/actions/runs/12876675701/job/35900136914?pr=650
Overview
This PR refactors the SkeletonKeyOrchestrator to properly inherit from PromptSendingOrchestrator instead of Orchestrator. The refactoring improves code organization and reliability while maintaining all existing functionality. It focuses on leveraging the parent class's capabilities for prompt handling and conversation management.
Key Features
Method Refactoring:
send_skeleton_key_with_prompts_async
to use parent class's batching capabilitiessend_skeleton_key_with_prompt_async
to maintain consistent conversation context_create_normalizer_request
for request creationRequest Handling:
Memory Management:
Backward Compatibility:
Related Issues
MAINT: Refactor Skeleton Key to be a subclass of PromptSendingOrchestrator #599
Next Steps (DONE):