hackagent 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. hackagent/__init__.py +23 -0
  2. hackagent/agent.py +193 -0
  3. hackagent/api/__init__.py +1 -0
  4. hackagent/api/agent/__init__.py +1 -0
  5. hackagent/api/agent/agent_create.py +340 -0
  6. hackagent/api/agent/agent_destroy.py +136 -0
  7. hackagent/api/agent/agent_list.py +234 -0
  8. hackagent/api/agent/agent_partial_update.py +354 -0
  9. hackagent/api/agent/agent_retrieve.py +227 -0
  10. hackagent/api/agent/agent_update.py +354 -0
  11. hackagent/api/attack/__init__.py +1 -0
  12. hackagent/api/attack/attack_create.py +264 -0
  13. hackagent/api/attack/attack_destroy.py +140 -0
  14. hackagent/api/attack/attack_list.py +242 -0
  15. hackagent/api/attack/attack_partial_update.py +278 -0
  16. hackagent/api/attack/attack_retrieve.py +235 -0
  17. hackagent/api/attack/attack_update.py +278 -0
  18. hackagent/api/key/__init__.py +1 -0
  19. hackagent/api/key/key_create.py +168 -0
  20. hackagent/api/key/key_destroy.py +97 -0
  21. hackagent/api/key/key_list.py +158 -0
  22. hackagent/api/key/key_retrieve.py +150 -0
  23. hackagent/api/prompt/__init__.py +1 -0
  24. hackagent/api/prompt/prompt_create.py +160 -0
  25. hackagent/api/prompt/prompt_destroy.py +98 -0
  26. hackagent/api/prompt/prompt_list.py +173 -0
  27. hackagent/api/prompt/prompt_partial_update.py +174 -0
  28. hackagent/api/prompt/prompt_retrieve.py +151 -0
  29. hackagent/api/prompt/prompt_update.py +174 -0
  30. hackagent/api/result/__init__.py +1 -0
  31. hackagent/api/result/result_create.py +160 -0
  32. hackagent/api/result/result_destroy.py +98 -0
  33. hackagent/api/result/result_list.py +233 -0
  34. hackagent/api/result/result_partial_update.py +178 -0
  35. hackagent/api/result/result_retrieve.py +151 -0
  36. hackagent/api/result/result_trace_create.py +178 -0
  37. hackagent/api/result/result_update.py +174 -0
  38. hackagent/api/run/__init__.py +1 -0
  39. hackagent/api/run/run_create.py +172 -0
  40. hackagent/api/run/run_destroy.py +104 -0
  41. hackagent/api/run/run_list.py +260 -0
  42. hackagent/api/run/run_partial_update.py +186 -0
  43. hackagent/api/run/run_result_create.py +178 -0
  44. hackagent/api/run/run_retrieve.py +163 -0
  45. hackagent/api/run/run_run_tests_create.py +172 -0
  46. hackagent/api/run/run_update.py +186 -0
  47. hackagent/attacks/AdvPrefix/README.md +7 -0
  48. hackagent/attacks/AdvPrefix/__init__.py +0 -0
  49. hackagent/attacks/AdvPrefix/completer.py +438 -0
  50. hackagent/attacks/AdvPrefix/config.py +59 -0
  51. hackagent/attacks/AdvPrefix/preprocessing.py +521 -0
  52. hackagent/attacks/AdvPrefix/scorer.py +259 -0
  53. hackagent/attacks/AdvPrefix/scorer_parser.py +498 -0
  54. hackagent/attacks/AdvPrefix/selector.py +246 -0
  55. hackagent/attacks/AdvPrefix/step1_generate.py +324 -0
  56. hackagent/attacks/AdvPrefix/step4_compute_ce.py +293 -0
  57. hackagent/attacks/AdvPrefix/step6_get_completions.py +387 -0
  58. hackagent/attacks/AdvPrefix/step7_evaluate_responses.py +289 -0
  59. hackagent/attacks/AdvPrefix/step8_aggregate_evaluations.py +177 -0
  60. hackagent/attacks/AdvPrefix/step9_select_prefixes.py +59 -0
  61. hackagent/attacks/AdvPrefix/utils.py +192 -0
  62. hackagent/attacks/__init__.py +6 -0
  63. hackagent/attacks/advprefix.py +1136 -0
  64. hackagent/attacks/base.py +50 -0
  65. hackagent/attacks/strategies.py +539 -0
  66. hackagent/branding.py +143 -0
  67. hackagent/client.py +328 -0
  68. hackagent/errors.py +31 -0
  69. hackagent/logger.py +67 -0
  70. hackagent/models/__init__.py +71 -0
  71. hackagent/models/agent.py +240 -0
  72. hackagent/models/agent_request.py +169 -0
  73. hackagent/models/agent_type_enum.py +12 -0
  74. hackagent/models/attack.py +154 -0
  75. hackagent/models/attack_request.py +82 -0
  76. hackagent/models/evaluation_status_enum.py +14 -0
  77. hackagent/models/organization_minimal.py +68 -0
  78. hackagent/models/paginated_agent_list.py +123 -0
  79. hackagent/models/paginated_attack_list.py +123 -0
  80. hackagent/models/paginated_prompt_list.py +123 -0
  81. hackagent/models/paginated_result_list.py +123 -0
  82. hackagent/models/paginated_run_list.py +123 -0
  83. hackagent/models/paginated_user_api_key_list.py +123 -0
  84. hackagent/models/patched_agent_request.py +176 -0
  85. hackagent/models/patched_attack_request.py +92 -0
  86. hackagent/models/patched_prompt_request.py +162 -0
  87. hackagent/models/patched_result_request.py +237 -0
  88. hackagent/models/patched_run_request.py +138 -0
  89. hackagent/models/prompt.py +226 -0
  90. hackagent/models/prompt_request.py +155 -0
  91. hackagent/models/result.py +294 -0
  92. hackagent/models/result_list_evaluation_status.py +14 -0
  93. hackagent/models/result_request.py +232 -0
  94. hackagent/models/run.py +233 -0
  95. hackagent/models/run_list_status.py +12 -0
  96. hackagent/models/run_request.py +133 -0
  97. hackagent/models/status_enum.py +12 -0
  98. hackagent/models/step_type_enum.py +14 -0
  99. hackagent/models/trace.py +121 -0
  100. hackagent/models/trace_request.py +94 -0
  101. hackagent/models/user_api_key.py +201 -0
  102. hackagent/models/user_api_key_request.py +73 -0
  103. hackagent/models/user_profile_minimal.py +76 -0
  104. hackagent/py.typed +1 -0
  105. hackagent/router/__init__.py +11 -0
  106. hackagent/router/adapters/__init__.py +5 -0
  107. hackagent/router/adapters/google_adk.py +658 -0
  108. hackagent/router/adapters/litellm_adapter.py +290 -0
  109. hackagent/router/base.py +48 -0
  110. hackagent/router/router.py +753 -0
  111. hackagent/types.py +46 -0
  112. hackagent/utils.py +61 -0
  113. hackagent/vulnerabilities/__init__.py +0 -0
  114. hackagent-0.1.0.dist-info/LICENSE +202 -0
  115. hackagent-0.1.0.dist-info/METADATA +173 -0
  116. hackagent-0.1.0.dist-info/RECORD +117 -0
  117. hackagent-0.1.0.dist-info/WHEEL +4 -0
@@ -0,0 +1,240 @@
1
+ import datetime
2
+ from collections.abc import Mapping
3
+ from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
4
+ from uuid import UUID
5
+
6
+ from attrs import define as _attrs_define
7
+ from attrs import field as _attrs_field
8
+ from dateutil.parser import isoparse
9
+
10
+ from ..models.agent_type_enum import AgentTypeEnum
11
+ from ..types import UNSET, Unset
12
+
13
+ if TYPE_CHECKING:
14
+ from ..models.organization_minimal import OrganizationMinimal
15
+ from ..models.user_profile_minimal import UserProfileMinimal
16
+
17
+
18
+ T = TypeVar("T", bound="Agent")
19
+
20
+
21
+ @_attrs_define
22
+ class Agent:
23
+ """Serializes Agent model instances to JSON and validates data for creating
24
+ or updating Agent instances.
25
+
26
+ This serializer provides a comprehensive representation of an Agent,
27
+ including its type, endpoint, and nested details for related 'organization'
28
+ and 'owner' for read operations, while allowing 'organization' and 'owner' IDs
29
+ for write operations.
30
+
31
+ Attributes:
32
+ organization_detail (OrganizationMinimalSerializer): Read-only nested
33
+ serializer for the agent's organization. Displays minimal details.
34
+ owner_detail (UserProfileMinimalSerializer): Read-only nested serializer
35
+ for the agent's owner's user profile. Displays minimal details.
36
+ Can be null if the agent has no owner or the owner has no profile.
37
+ type (CharField): The type of the agent (e.g., GENERIC_ADK, OPENAI_SDK).
38
+ Uses the choices defined in the Agent model's AgentType enum.
39
+
40
+ Meta:
41
+ model (Agent): The model class that this serializer works with.
42
+ fields (tuple): The fields to include in the serialized output.
43
+ Includes standard Agent fields like 'endpoint', 'type',
44
+ and the read-only nested details.
45
+ read_only_fields (tuple): Fields that are read-only and cannot be
46
+ set during create/update operations through this serializer.
47
+ This includes 'id', 'created_at', 'updated_at', and the
48
+ nested detail fields.
49
+
50
+ Attributes:
51
+ id (UUID):
52
+ name (str):
53
+ endpoint (str): The primary API endpoint URL for interacting with the agent.
54
+ organization (UUID):
55
+ organization_detail (OrganizationMinimal):
56
+ owner_detail (Union['UserProfileMinimal', None]):
57
+ created_at (datetime.datetime):
58
+ updated_at (datetime.datetime):
59
+ agent_type (Union[Unset, AgentTypeEnum]): * `LITELMM` - LiteLLM
60
+ * `OPENAI_SDK` - OpenAI SDK/API
61
+ * `GOOGLE_ADK` - Google ADK
62
+ * `OTHER` - Other/Proprietary
63
+ * `UNKNOWN` - Unknown
64
+ description (Union[Unset, str]):
65
+ metadata (Union[Unset, Any]): Optional JSON data providing specific details and configuration. Structure depends
66
+ heavily on Agent Type. Examples:
67
+ - For GENERIC_ADK: {'adk_app_name': 'my_adk_app', 'protocol_version': '1.0'}
68
+ - For OPENAI_SDK: {'model': 'gpt-4-turbo', 'api_key_secret_name': 'MY_OPENAI_KEY', 'instructions': 'You are a
69
+ helpful assistant.'}
70
+ - For GOOGLE_ADK: {'project_id': 'my-gcp-project', 'location': 'us-central1'}
71
+ - General applicable: {'version': '1.2.0', 'custom_headers': {'X-Custom-Header': 'value'}}
72
+ owner (Union[None, Unset, int]):
73
+ """
74
+
75
+ id: UUID
76
+ name: str
77
+ endpoint: str
78
+ organization: UUID
79
+ organization_detail: "OrganizationMinimal"
80
+ owner_detail: Union["UserProfileMinimal", None]
81
+ created_at: datetime.datetime
82
+ updated_at: datetime.datetime
83
+ agent_type: Union[Unset, AgentTypeEnum] = UNSET
84
+ description: Union[Unset, str] = UNSET
85
+ metadata: Union[Unset, Any] = UNSET
86
+ owner: Union[None, Unset, int] = UNSET
87
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
88
+
89
+ def to_dict(self) -> dict[str, Any]:
90
+ from ..models.user_profile_minimal import UserProfileMinimal
91
+
92
+ id = str(self.id)
93
+
94
+ name = self.name
95
+
96
+ endpoint = self.endpoint
97
+
98
+ organization = str(self.organization)
99
+
100
+ organization_detail = self.organization_detail.to_dict()
101
+
102
+ owner_detail: Union[None, dict[str, Any]]
103
+ if isinstance(self.owner_detail, UserProfileMinimal):
104
+ owner_detail = self.owner_detail.to_dict()
105
+ else:
106
+ owner_detail = self.owner_detail
107
+
108
+ created_at = self.created_at.isoformat()
109
+
110
+ updated_at = self.updated_at.isoformat()
111
+
112
+ agent_type: Union[Unset, str] = UNSET
113
+ if not isinstance(self.agent_type, Unset):
114
+ agent_type = self.agent_type.value
115
+
116
+ description = self.description
117
+
118
+ metadata = self.metadata
119
+
120
+ owner: Union[None, Unset, int]
121
+ if isinstance(self.owner, Unset):
122
+ owner = UNSET
123
+ else:
124
+ owner = self.owner
125
+
126
+ field_dict: dict[str, Any] = {}
127
+ field_dict.update(self.additional_properties)
128
+ field_dict.update(
129
+ {
130
+ "id": id,
131
+ "name": name,
132
+ "endpoint": endpoint,
133
+ "organization": organization,
134
+ "organization_detail": organization_detail,
135
+ "owner_detail": owner_detail,
136
+ "created_at": created_at,
137
+ "updated_at": updated_at,
138
+ }
139
+ )
140
+ if agent_type is not UNSET:
141
+ field_dict["agent_type"] = agent_type
142
+ if description is not UNSET:
143
+ field_dict["description"] = description
144
+ if metadata is not UNSET:
145
+ field_dict["metadata"] = metadata
146
+ if owner is not UNSET:
147
+ field_dict["owner"] = owner
148
+
149
+ return field_dict
150
+
151
+ @classmethod
152
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
153
+ from ..models.organization_minimal import OrganizationMinimal
154
+ from ..models.user_profile_minimal import UserProfileMinimal
155
+
156
+ d = dict(src_dict)
157
+ id = UUID(d.pop("id"))
158
+
159
+ name = d.pop("name")
160
+
161
+ endpoint = d.pop("endpoint")
162
+
163
+ organization = UUID(d.pop("organization"))
164
+
165
+ organization_detail = OrganizationMinimal.from_dict(
166
+ d.pop("organization_detail")
167
+ )
168
+
169
+ def _parse_owner_detail(data: object) -> Union["UserProfileMinimal", None]:
170
+ if data is None:
171
+ return data
172
+ try:
173
+ if not isinstance(data, dict):
174
+ raise TypeError()
175
+ owner_detail_type_1 = UserProfileMinimal.from_dict(data)
176
+
177
+ return owner_detail_type_1
178
+ except: # noqa: E722
179
+ pass
180
+ return cast(Union["UserProfileMinimal", None], data)
181
+
182
+ owner_detail = _parse_owner_detail(d.pop("owner_detail"))
183
+
184
+ created_at = isoparse(d.pop("created_at"))
185
+
186
+ updated_at = isoparse(d.pop("updated_at"))
187
+
188
+ _agent_type = d.pop("agent_type", UNSET)
189
+ agent_type: Union[Unset, AgentTypeEnum]
190
+ if isinstance(_agent_type, Unset):
191
+ agent_type = UNSET
192
+ else:
193
+ agent_type = AgentTypeEnum(_agent_type)
194
+
195
+ description = d.pop("description", UNSET)
196
+
197
+ metadata = d.pop("metadata", UNSET)
198
+
199
+ def _parse_owner(data: object) -> Union[None, Unset, int]:
200
+ if data is None:
201
+ return data
202
+ if isinstance(data, Unset):
203
+ return data
204
+ return cast(Union[None, Unset, int], data)
205
+
206
+ owner = _parse_owner(d.pop("owner", UNSET))
207
+
208
+ agent = cls(
209
+ id=id,
210
+ name=name,
211
+ endpoint=endpoint,
212
+ organization=organization,
213
+ organization_detail=organization_detail,
214
+ owner_detail=owner_detail,
215
+ created_at=created_at,
216
+ updated_at=updated_at,
217
+ agent_type=agent_type,
218
+ description=description,
219
+ metadata=metadata,
220
+ owner=owner,
221
+ )
222
+
223
+ agent.additional_properties = d
224
+ return agent
225
+
226
+ @property
227
+ def additional_keys(self) -> list[str]:
228
+ return list(self.additional_properties.keys())
229
+
230
+ def __getitem__(self, key: str) -> Any:
231
+ return self.additional_properties[key]
232
+
233
+ def __setitem__(self, key: str, value: Any) -> None:
234
+ self.additional_properties[key] = value
235
+
236
+ def __delitem__(self, key: str) -> None:
237
+ del self.additional_properties[key]
238
+
239
+ def __contains__(self, key: str) -> bool:
240
+ return key in self.additional_properties
@@ -0,0 +1,169 @@
1
+ from collections.abc import Mapping
2
+ from typing import Any, TypeVar, Union, cast
3
+ from uuid import UUID
4
+
5
+ from attrs import define as _attrs_define
6
+ from attrs import field as _attrs_field
7
+
8
+ from ..models.agent_type_enum import AgentTypeEnum
9
+ from ..types import UNSET, Unset
10
+
11
+ T = TypeVar("T", bound="AgentRequest")
12
+
13
+
14
+ @_attrs_define
15
+ class AgentRequest:
16
+ """Serializes Agent model instances to JSON and validates data for creating
17
+ or updating Agent instances.
18
+
19
+ This serializer provides a comprehensive representation of an Agent,
20
+ including its type, endpoint, and nested details for related 'organization'
21
+ and 'owner' for read operations, while allowing 'organization' and 'owner' IDs
22
+ for write operations.
23
+
24
+ Attributes:
25
+ organization_detail (OrganizationMinimalSerializer): Read-only nested
26
+ serializer for the agent's organization. Displays minimal details.
27
+ owner_detail (UserProfileMinimalSerializer): Read-only nested serializer
28
+ for the agent's owner's user profile. Displays minimal details.
29
+ Can be null if the agent has no owner or the owner has no profile.
30
+ type (CharField): The type of the agent (e.g., GENERIC_ADK, OPENAI_SDK).
31
+ Uses the choices defined in the Agent model's AgentType enum.
32
+
33
+ Meta:
34
+ model (Agent): The model class that this serializer works with.
35
+ fields (tuple): The fields to include in the serialized output.
36
+ Includes standard Agent fields like 'endpoint', 'type',
37
+ and the read-only nested details.
38
+ read_only_fields (tuple): Fields that are read-only and cannot be
39
+ set during create/update operations through this serializer.
40
+ This includes 'id', 'created_at', 'updated_at', and the
41
+ nested detail fields.
42
+
43
+ Attributes:
44
+ name (str):
45
+ endpoint (str): The primary API endpoint URL for interacting with the agent.
46
+ organization (UUID):
47
+ agent_type (Union[Unset, AgentTypeEnum]): * `LITELMM` - LiteLLM
48
+ * `OPENAI_SDK` - OpenAI SDK/API
49
+ * `GOOGLE_ADK` - Google ADK
50
+ * `OTHER` - Other/Proprietary
51
+ * `UNKNOWN` - Unknown
52
+ description (Union[Unset, str]):
53
+ metadata (Union[Unset, Any]): Optional JSON data providing specific details and configuration. Structure depends
54
+ heavily on Agent Type. Examples:
55
+ - For GENERIC_ADK: {'adk_app_name': 'my_adk_app', 'protocol_version': '1.0'}
56
+ - For OPENAI_SDK: {'model': 'gpt-4-turbo', 'api_key_secret_name': 'MY_OPENAI_KEY', 'instructions': 'You are a
57
+ helpful assistant.'}
58
+ - For GOOGLE_ADK: {'project_id': 'my-gcp-project', 'location': 'us-central1'}
59
+ - General applicable: {'version': '1.2.0', 'custom_headers': {'X-Custom-Header': 'value'}}
60
+ owner (Union[None, Unset, int]):
61
+ """
62
+
63
+ name: str
64
+ endpoint: str
65
+ organization: UUID
66
+ agent_type: Union[Unset, AgentTypeEnum] = UNSET
67
+ description: Union[Unset, str] = UNSET
68
+ metadata: Union[Unset, Any] = UNSET
69
+ owner: Union[None, Unset, int] = UNSET
70
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
71
+
72
+ def to_dict(self) -> dict[str, Any]:
73
+ name = self.name
74
+
75
+ endpoint = self.endpoint
76
+
77
+ organization = str(self.organization)
78
+
79
+ agent_type: Union[Unset, str] = UNSET
80
+ if not isinstance(self.agent_type, Unset):
81
+ agent_type = self.agent_type.value
82
+
83
+ description = self.description
84
+
85
+ metadata = self.metadata
86
+
87
+ owner: Union[None, Unset, int]
88
+ if isinstance(self.owner, Unset):
89
+ owner = UNSET
90
+ else:
91
+ owner = self.owner
92
+
93
+ field_dict: dict[str, Any] = {}
94
+ field_dict.update(self.additional_properties)
95
+ field_dict.update(
96
+ {
97
+ "name": name,
98
+ "endpoint": endpoint,
99
+ "organization": organization,
100
+ }
101
+ )
102
+ if agent_type is not UNSET:
103
+ field_dict["agent_type"] = agent_type
104
+ if description is not UNSET:
105
+ field_dict["description"] = description
106
+ if metadata is not UNSET:
107
+ field_dict["metadata"] = metadata
108
+ if owner is not UNSET:
109
+ field_dict["owner"] = owner
110
+
111
+ return field_dict
112
+
113
+ @classmethod
114
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
115
+ d = dict(src_dict)
116
+ name = d.pop("name")
117
+
118
+ endpoint = d.pop("endpoint")
119
+
120
+ organization = UUID(d.pop("organization"))
121
+
122
+ _agent_type = d.pop("agent_type", UNSET)
123
+ agent_type: Union[Unset, AgentTypeEnum]
124
+ if isinstance(_agent_type, Unset):
125
+ agent_type = UNSET
126
+ else:
127
+ agent_type = AgentTypeEnum(_agent_type)
128
+
129
+ description = d.pop("description", UNSET)
130
+
131
+ metadata = d.pop("metadata", UNSET)
132
+
133
+ def _parse_owner(data: object) -> Union[None, Unset, int]:
134
+ if data is None:
135
+ return data
136
+ if isinstance(data, Unset):
137
+ return data
138
+ return cast(Union[None, Unset, int], data)
139
+
140
+ owner = _parse_owner(d.pop("owner", UNSET))
141
+
142
+ agent_request = cls(
143
+ name=name,
144
+ endpoint=endpoint,
145
+ organization=organization,
146
+ agent_type=agent_type,
147
+ description=description,
148
+ metadata=metadata,
149
+ owner=owner,
150
+ )
151
+
152
+ agent_request.additional_properties = d
153
+ return agent_request
154
+
155
+ @property
156
+ def additional_keys(self) -> list[str]:
157
+ return list(self.additional_properties.keys())
158
+
159
+ def __getitem__(self, key: str) -> Any:
160
+ return self.additional_properties[key]
161
+
162
+ def __setitem__(self, key: str, value: Any) -> None:
163
+ self.additional_properties[key] = value
164
+
165
+ def __delitem__(self, key: str) -> None:
166
+ del self.additional_properties[key]
167
+
168
+ def __contains__(self, key: str) -> bool:
169
+ return key in self.additional_properties
@@ -0,0 +1,12 @@
1
+ from enum import Enum
2
+
3
+
4
+ class AgentTypeEnum(str, Enum):
5
+ GOOGLE_ADK = "GOOGLE_ADK"
6
+ LITELMM = "LITELMM"
7
+ OPENAI_SDK = "OPENAI_SDK"
8
+ OTHER = "OTHER"
9
+ UNKNOWN = "UNKNOWN"
10
+
11
+ def __str__(self) -> str:
12
+ return str(self.value)
@@ -0,0 +1,154 @@
1
+ import datetime
2
+ from collections.abc import Mapping
3
+ from typing import Any, TypeVar, Union, cast
4
+ from uuid import UUID
5
+
6
+ from attrs import define as _attrs_define
7
+ from attrs import field as _attrs_field
8
+ from dateutil.parser import isoparse
9
+
10
+ T = TypeVar("T", bound="Attack")
11
+
12
+
13
+ @_attrs_define
14
+ class Attack:
15
+ """Serializer for the Attack model, which represents an Attack configuration.
16
+
17
+ Handles the conversion of Attack configuration instances to JSON (and vice-versa)
18
+ for API requests and responses. It includes read-only fields for related
19
+ object names (like agent_name, owner_username) for convenience in API outputs.
20
+
21
+ Attributes:
22
+ id (UUID):
23
+ type_ (str): A string identifier for the type of attack being configured (e.g., 'PREFIX_GENERATION',
24
+ 'PROMPT_INJECTION').
25
+ agent (UUID):
26
+ agent_name (str):
27
+ owner (Union[None, int]):
28
+ owner_username (str):
29
+ organization (UUID):
30
+ organization_name (str):
31
+ configuration (Any): JSON containing client-provided configuration for an attack using this definition.
32
+ created_at (datetime.datetime):
33
+ updated_at (datetime.datetime):
34
+ """
35
+
36
+ id: UUID
37
+ type_: str
38
+ agent: UUID
39
+ agent_name: str
40
+ owner: Union[None, int]
41
+ owner_username: str
42
+ organization: UUID
43
+ organization_name: str
44
+ configuration: Any
45
+ created_at: datetime.datetime
46
+ updated_at: datetime.datetime
47
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
48
+
49
+ def to_dict(self) -> dict[str, Any]:
50
+ id = str(self.id)
51
+
52
+ type_ = self.type_
53
+
54
+ agent = str(self.agent)
55
+
56
+ agent_name = self.agent_name
57
+
58
+ owner: Union[None, int]
59
+ owner = self.owner
60
+
61
+ owner_username = self.owner_username
62
+
63
+ organization = str(self.organization)
64
+
65
+ organization_name = self.organization_name
66
+
67
+ configuration = self.configuration
68
+
69
+ created_at = self.created_at.isoformat()
70
+
71
+ updated_at = self.updated_at.isoformat()
72
+
73
+ field_dict: dict[str, Any] = {}
74
+ field_dict.update(self.additional_properties)
75
+ field_dict.update(
76
+ {
77
+ "id": id,
78
+ "type": type_,
79
+ "agent": agent,
80
+ "agent_name": agent_name,
81
+ "owner": owner,
82
+ "owner_username": owner_username,
83
+ "organization": organization,
84
+ "organization_name": organization_name,
85
+ "configuration": configuration,
86
+ "created_at": created_at,
87
+ "updated_at": updated_at,
88
+ }
89
+ )
90
+
91
+ return field_dict
92
+
93
+ @classmethod
94
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
95
+ d = dict(src_dict)
96
+ id = UUID(d.pop("id"))
97
+
98
+ type_ = d.pop("type")
99
+
100
+ agent = UUID(d.pop("agent"))
101
+
102
+ agent_name = d.pop("agent_name")
103
+
104
+ def _parse_owner(data: object) -> Union[None, int]:
105
+ if data is None:
106
+ return data
107
+ return cast(Union[None, int], data)
108
+
109
+ owner = _parse_owner(d.pop("owner"))
110
+
111
+ owner_username = d.pop("owner_username")
112
+
113
+ organization = UUID(d.pop("organization"))
114
+
115
+ organization_name = d.pop("organization_name")
116
+
117
+ configuration = d.pop("configuration")
118
+
119
+ created_at = isoparse(d.pop("created_at"))
120
+
121
+ updated_at = isoparse(d.pop("updated_at"))
122
+
123
+ attack = cls(
124
+ id=id,
125
+ type_=type_,
126
+ agent=agent,
127
+ agent_name=agent_name,
128
+ owner=owner,
129
+ owner_username=owner_username,
130
+ organization=organization,
131
+ organization_name=organization_name,
132
+ configuration=configuration,
133
+ created_at=created_at,
134
+ updated_at=updated_at,
135
+ )
136
+
137
+ attack.additional_properties = d
138
+ return attack
139
+
140
+ @property
141
+ def additional_keys(self) -> list[str]:
142
+ return list(self.additional_properties.keys())
143
+
144
+ def __getitem__(self, key: str) -> Any:
145
+ return self.additional_properties[key]
146
+
147
+ def __setitem__(self, key: str, value: Any) -> None:
148
+ self.additional_properties[key] = value
149
+
150
+ def __delitem__(self, key: str) -> None:
151
+ del self.additional_properties[key]
152
+
153
+ def __contains__(self, key: str) -> bool:
154
+ return key in self.additional_properties
@@ -0,0 +1,82 @@
1
+ from collections.abc import Mapping
2
+ from typing import Any, TypeVar
3
+ from uuid import UUID
4
+
5
+ from attrs import define as _attrs_define
6
+ from attrs import field as _attrs_field
7
+
8
+ T = TypeVar("T", bound="AttackRequest")
9
+
10
+
11
+ @_attrs_define
12
+ class AttackRequest:
13
+ """Serializer for the Attack model, which represents an Attack configuration.
14
+
15
+ Handles the conversion of Attack configuration instances to JSON (and vice-versa)
16
+ for API requests and responses. It includes read-only fields for related
17
+ object names (like agent_name, owner_username) for convenience in API outputs.
18
+
19
+ Attributes:
20
+ type_ (str): A string identifier for the type of attack being configured (e.g., 'PREFIX_GENERATION',
21
+ 'PROMPT_INJECTION').
22
+ agent (UUID):
23
+ configuration (Any): JSON containing client-provided configuration for an attack using this definition.
24
+ """
25
+
26
+ type_: str
27
+ agent: UUID
28
+ configuration: Any
29
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
30
+
31
+ def to_dict(self) -> dict[str, Any]:
32
+ type_ = self.type_
33
+
34
+ agent = str(self.agent)
35
+
36
+ configuration = self.configuration
37
+
38
+ field_dict: dict[str, Any] = {}
39
+ field_dict.update(self.additional_properties)
40
+ field_dict.update(
41
+ {
42
+ "type": type_,
43
+ "agent": agent,
44
+ "configuration": configuration,
45
+ }
46
+ )
47
+
48
+ return field_dict
49
+
50
+ @classmethod
51
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
52
+ d = dict(src_dict)
53
+ type_ = d.pop("type")
54
+
55
+ agent = UUID(d.pop("agent"))
56
+
57
+ configuration = d.pop("configuration")
58
+
59
+ attack_request = cls(
60
+ type_=type_,
61
+ agent=agent,
62
+ configuration=configuration,
63
+ )
64
+
65
+ attack_request.additional_properties = d
66
+ return attack_request
67
+
68
+ @property
69
+ def additional_keys(self) -> list[str]:
70
+ return list(self.additional_properties.keys())
71
+
72
+ def __getitem__(self, key: str) -> Any:
73
+ return self.additional_properties[key]
74
+
75
+ def __setitem__(self, key: str, value: Any) -> None:
76
+ self.additional_properties[key] = value
77
+
78
+ def __delitem__(self, key: str) -> None:
79
+ del self.additional_properties[key]
80
+
81
+ def __contains__(self, key: str) -> bool:
82
+ return key in self.additional_properties
@@ -0,0 +1,14 @@
1
+ from enum import Enum
2
+
3
+
4
+ class EvaluationStatusEnum(str, Enum):
5
+ ERROR_AGENT_RESPONSE = "ERROR_AGENT_RESPONSE"
6
+ ERROR_TEST_FRAMEWORK = "ERROR_TEST_FRAMEWORK"
7
+ FAILED_CRITERIA = "FAILED_CRITERIA"
8
+ FAILED_JAILBREAK = "FAILED_JAILBREAK"
9
+ NOT_EVALUATED = "NOT_EVALUATED"
10
+ PASSED_CRITERIA = "PASSED_CRITERIA"
11
+ SUCCESSFUL_JAILBREAK = "SUCCESSFUL_JAILBREAK"
12
+
13
+ def __str__(self) -> str:
14
+ return str(self.value)