|
3 | 3 |
|
4 | 4 | import abc |
5 | 5 | import logging |
6 | | -from typing import Optional |
| 6 | +from typing import Any, Dict, Optional |
7 | 7 |
|
8 | 8 | from pyrit.memory import CentralMemory, MemoryInterface |
9 | 9 | from pyrit.models import Identifier, Message |
@@ -84,18 +84,27 @@ def dispose_db_engine(self) -> None: |
84 | 84 | """ |
85 | 85 | self._memory.dispose_engine() |
86 | 86 |
|
87 | | - def get_identifier(self) -> dict: |
| 87 | + def get_identifier(self) -> Dict[str, Any]: |
88 | 88 | """ |
89 | | - Get the identifier dictionary for the prompt target. |
| 89 | + Get an identifier dictionary for this prompt target. |
| 90 | +
|
| 91 | + This includes essential attributes needed for scorer evaluation and registry tracking. |
| 92 | + Subclasses should override this method to include additional relevant attributes |
| 93 | + (e.g., temperature, top_p) when available. |
90 | 94 |
|
91 | 95 | Returns: |
92 | | - dict: Dictionary containing the target's type, module, endpoint, and model name. |
| 96 | + Dict[str, Any]: A dictionary containing identification attributes. |
93 | 97 | """ |
94 | | - public_attributes = {} |
| 98 | + public_attributes: Dict[str, Any] = {} |
95 | 99 | public_attributes["__type__"] = self.__class__.__name__ |
96 | 100 | public_attributes["__module__"] = self.__class__.__module__ |
97 | 101 | if self._endpoint: |
98 | 102 | public_attributes["endpoint"] = self._endpoint |
99 | 103 | if self._model_name: |
100 | 104 | public_attributes["model_name"] = self._model_name |
| 105 | + # Include temperature and top_p if available (set by subclasses) |
| 106 | + if hasattr(self, "_temperature") and self._temperature is not None: |
| 107 | + public_attributes["temperature"] = self._temperature |
| 108 | + if hasattr(self, "_top_p") and self._top_p is not None: |
| 109 | + public_attributes["top_p"] = self._top_p |
101 | 110 | return public_attributes |
0 commit comments