-
Notifications
You must be signed in to change notification settings - Fork 655
FEAT: Adding TargetIdentifier
#1336
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c82f8ed
first_commit
jsong468 4428df9
first_commitv2
jsong468 65b36a5
merge conflicts
jsong468 6e279a9
tests
jsong468 f123770
deprecation 0.14.0
jsong468 08719ae
use normalize method
jsong468 6bc02c6
scorer_registry change
jsong468 4878fc9
Merge branch 'main' into target_identifier_refactor
jsong468 ad46462
fix pre-commit and import
jsong468 b8b3911
fix converter unit tests
jsong468 260d3d3
Merge branch 'main' into target_identifier_refactor
jsong468 30fc2a1
unique_name
jsong468 3e5f591
revert unique name change
jsong468 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT license. | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from dataclasses import dataclass | ||
| from typing import Any, Dict, Optional, Type, cast | ||
|
|
||
| from pyrit.identifiers.identifier import Identifier | ||
|
|
||
|
|
||
| @dataclass(frozen=True) | ||
| class TargetIdentifier(Identifier): | ||
| """ | ||
| Identifier for PromptTarget instances. | ||
|
|
||
| This frozen dataclass extends Identifier with target-specific fields. | ||
| It provides a stable, hashable identifier for prompt targets that can be | ||
| used for scorer evaluation, registry tracking, and memory storage. | ||
| """ | ||
|
|
||
| endpoint: str = "" | ||
jsong468 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| """The target endpoint URL.""" | ||
|
|
||
| model_name: str = "" | ||
| """The model or deployment name.""" | ||
|
|
||
| temperature: Optional[float] = None | ||
| """The temperature parameter for generation.""" | ||
|
|
||
| top_p: Optional[float] = None | ||
| """The top_p parameter for generation.""" | ||
|
|
||
| max_requests_per_minute: Optional[int] = None | ||
| """Maximum number of requests per minute.""" | ||
|
|
||
| target_specific_params: Optional[Dict[str, Any]] = None | ||
| """Additional target-specific parameters.""" | ||
|
|
||
ValbuenaVC marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| @classmethod | ||
| def from_dict(cls: Type["TargetIdentifier"], data: dict[str, Any]) -> "TargetIdentifier": | ||
| """ | ||
| Create a TargetIdentifier from a dictionary (e.g., retrieved from database). | ||
|
|
||
| Extends the base Identifier.from_dict() to handle legacy key mappings. | ||
|
|
||
| Args: | ||
| data: The dictionary representation. | ||
|
|
||
| Returns: | ||
| TargetIdentifier: A new TargetIdentifier instance. | ||
| """ | ||
| # Delegate to parent class for standard processing | ||
| result = Identifier.from_dict.__func__(cls, data) # type: ignore[attr-defined] | ||
| return cast(TargetIdentifier, result) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.