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,155 @@
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 ..types import UNSET, Unset
9
+
10
+ T = TypeVar("T", bound="PromptRequest")
11
+
12
+
13
+ @_attrs_define
14
+ class PromptRequest:
15
+ """Serializer for the Prompt model.
16
+
17
+ Attributes:
18
+ name (str):
19
+ prompt_text (str):
20
+ organization (UUID):
21
+ category (Union[Unset, str]): Primary category for grouping prompts (e.g., Evasion, Harmful Content).
22
+ tags (Union[Unset, Any]): Optional JSON list of tags for classification (e.g., ["PII", "Malware"])
23
+ evaluation_criteria (Union[Unset, str]): Description of how success/failure should be judged for this specific
24
+ prompt.
25
+ expected_tool_calls (Union[Unset, Any]): JSON list of expected tool calls, e.g., [{"tool_name": "...",
26
+ "tool_input": {...}}]
27
+ expected_output_pattern (Union[Unset, str]): Optional regex pattern to match against the final response.
28
+ reference_output (Union[Unset, str]): Optional ideal/reference final output text.
29
+ owner (Union[None, Unset, int]):
30
+ """
31
+
32
+ name: str
33
+ prompt_text: str
34
+ organization: UUID
35
+ category: Union[Unset, str] = UNSET
36
+ tags: Union[Unset, Any] = UNSET
37
+ evaluation_criteria: Union[Unset, str] = UNSET
38
+ expected_tool_calls: Union[Unset, Any] = UNSET
39
+ expected_output_pattern: Union[Unset, str] = UNSET
40
+ reference_output: Union[Unset, str] = UNSET
41
+ owner: Union[None, Unset, int] = UNSET
42
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
43
+
44
+ def to_dict(self) -> dict[str, Any]:
45
+ name = self.name
46
+
47
+ prompt_text = self.prompt_text
48
+
49
+ organization = str(self.organization)
50
+
51
+ category = self.category
52
+
53
+ tags = self.tags
54
+
55
+ evaluation_criteria = self.evaluation_criteria
56
+
57
+ expected_tool_calls = self.expected_tool_calls
58
+
59
+ expected_output_pattern = self.expected_output_pattern
60
+
61
+ reference_output = self.reference_output
62
+
63
+ owner: Union[None, Unset, int]
64
+ if isinstance(self.owner, Unset):
65
+ owner = UNSET
66
+ else:
67
+ owner = self.owner
68
+
69
+ field_dict: dict[str, Any] = {}
70
+ field_dict.update(self.additional_properties)
71
+ field_dict.update(
72
+ {
73
+ "name": name,
74
+ "prompt_text": prompt_text,
75
+ "organization": organization,
76
+ }
77
+ )
78
+ if category is not UNSET:
79
+ field_dict["category"] = category
80
+ if tags is not UNSET:
81
+ field_dict["tags"] = tags
82
+ if evaluation_criteria is not UNSET:
83
+ field_dict["evaluation_criteria"] = evaluation_criteria
84
+ if expected_tool_calls is not UNSET:
85
+ field_dict["expected_tool_calls"] = expected_tool_calls
86
+ if expected_output_pattern is not UNSET:
87
+ field_dict["expected_output_pattern"] = expected_output_pattern
88
+ if reference_output is not UNSET:
89
+ field_dict["reference_output"] = reference_output
90
+ if owner is not UNSET:
91
+ field_dict["owner"] = owner
92
+
93
+ return field_dict
94
+
95
+ @classmethod
96
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
97
+ d = dict(src_dict)
98
+ name = d.pop("name")
99
+
100
+ prompt_text = d.pop("prompt_text")
101
+
102
+ organization = UUID(d.pop("organization"))
103
+
104
+ category = d.pop("category", UNSET)
105
+
106
+ tags = d.pop("tags", UNSET)
107
+
108
+ evaluation_criteria = d.pop("evaluation_criteria", UNSET)
109
+
110
+ expected_tool_calls = d.pop("expected_tool_calls", UNSET)
111
+
112
+ expected_output_pattern = d.pop("expected_output_pattern", UNSET)
113
+
114
+ reference_output = d.pop("reference_output", UNSET)
115
+
116
+ def _parse_owner(data: object) -> Union[None, Unset, int]:
117
+ if data is None:
118
+ return data
119
+ if isinstance(data, Unset):
120
+ return data
121
+ return cast(Union[None, Unset, int], data)
122
+
123
+ owner = _parse_owner(d.pop("owner", UNSET))
124
+
125
+ prompt_request = cls(
126
+ name=name,
127
+ prompt_text=prompt_text,
128
+ organization=organization,
129
+ category=category,
130
+ tags=tags,
131
+ evaluation_criteria=evaluation_criteria,
132
+ expected_tool_calls=expected_tool_calls,
133
+ expected_output_pattern=expected_output_pattern,
134
+ reference_output=reference_output,
135
+ owner=owner,
136
+ )
137
+
138
+ prompt_request.additional_properties = d
139
+ return prompt_request
140
+
141
+ @property
142
+ def additional_keys(self) -> list[str]:
143
+ return list(self.additional_properties.keys())
144
+
145
+ def __getitem__(self, key: str) -> Any:
146
+ return self.additional_properties[key]
147
+
148
+ def __setitem__(self, key: str, value: Any) -> None:
149
+ self.additional_properties[key] = value
150
+
151
+ def __delitem__(self, key: str) -> None:
152
+ del self.additional_properties[key]
153
+
154
+ def __contains__(self, key: str) -> bool:
155
+ return key in self.additional_properties
@@ -0,0 +1,294 @@
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.evaluation_status_enum import EvaluationStatusEnum
11
+ from ..types import UNSET, Unset
12
+
13
+ if TYPE_CHECKING:
14
+ from ..models.trace import Trace
15
+
16
+
17
+ T = TypeVar("T", bound="Result")
18
+
19
+
20
+ @_attrs_define
21
+ class Result:
22
+ """Serializer for the Result model, often nested in RunSerializer.
23
+
24
+ Attributes:
25
+ id (UUID):
26
+ run (UUID):
27
+ run_id (UUID):
28
+ prompt_name (Union[None, str]):
29
+ timestamp (datetime.datetime):
30
+ traces (list['Trace']):
31
+ prompt (Union[None, UUID, Unset]):
32
+ request_payload (Union[Unset, Any]): Payload sent to agent or relevant data for client-submitted results.
33
+ response_status_code (Union[None, Unset, int]):
34
+ response_headers (Union[Unset, Any]):
35
+ response_body (Union[None, Unset, str]):
36
+ latency_ms (Union[None, Unset, int]):
37
+ detected_tool_calls (Union[Unset, Any]):
38
+ evaluation_status (Union[Unset, EvaluationStatusEnum]): * `NOT_EVALUATED` - Not Evaluated
39
+ * `SUCCESSFUL_JAILBREAK` - Successful Jailbreak
40
+ * `FAILED_JAILBREAK` - Failed Jailbreak (Mitigated/Refused)
41
+ * `ERROR_AGENT_RESPONSE` - Error in Agent Response
42
+ * `ERROR_TEST_FRAMEWORK` - Error in Test Framework
43
+ * `PASSED_CRITERIA` - Passed Criteria (Not Jailbreak)
44
+ * `FAILED_CRITERIA` - Failed Criteria (Not Jailbreak)
45
+ evaluation_notes (Union[Unset, str]):
46
+ evaluation_metrics (Union[Unset, Any]):
47
+ agent_specific_data (Union[Unset, Any]):
48
+ """
49
+
50
+ id: UUID
51
+ run: UUID
52
+ run_id: UUID
53
+ prompt_name: Union[None, str]
54
+ timestamp: datetime.datetime
55
+ traces: list["Trace"]
56
+ prompt: Union[None, UUID, Unset] = UNSET
57
+ request_payload: Union[Unset, Any] = UNSET
58
+ response_status_code: Union[None, Unset, int] = UNSET
59
+ response_headers: Union[Unset, Any] = UNSET
60
+ response_body: Union[None, Unset, str] = UNSET
61
+ latency_ms: Union[None, Unset, int] = UNSET
62
+ detected_tool_calls: Union[Unset, Any] = UNSET
63
+ evaluation_status: Union[Unset, EvaluationStatusEnum] = UNSET
64
+ evaluation_notes: Union[Unset, str] = UNSET
65
+ evaluation_metrics: Union[Unset, Any] = UNSET
66
+ agent_specific_data: Union[Unset, Any] = UNSET
67
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
68
+
69
+ def to_dict(self) -> dict[str, Any]:
70
+ id = str(self.id)
71
+
72
+ run = str(self.run)
73
+
74
+ run_id = str(self.run_id)
75
+
76
+ prompt_name: Union[None, str]
77
+ prompt_name = self.prompt_name
78
+
79
+ timestamp = self.timestamp.isoformat()
80
+
81
+ traces = []
82
+ for traces_item_data in self.traces:
83
+ traces_item = traces_item_data.to_dict()
84
+ traces.append(traces_item)
85
+
86
+ prompt: Union[None, Unset, str]
87
+ if isinstance(self.prompt, Unset):
88
+ prompt = UNSET
89
+ elif isinstance(self.prompt, UUID):
90
+ prompt = str(self.prompt)
91
+ else:
92
+ prompt = self.prompt
93
+
94
+ request_payload = self.request_payload
95
+
96
+ response_status_code: Union[None, Unset, int]
97
+ if isinstance(self.response_status_code, Unset):
98
+ response_status_code = UNSET
99
+ else:
100
+ response_status_code = self.response_status_code
101
+
102
+ response_headers = self.response_headers
103
+
104
+ response_body: Union[None, Unset, str]
105
+ if isinstance(self.response_body, Unset):
106
+ response_body = UNSET
107
+ else:
108
+ response_body = self.response_body
109
+
110
+ latency_ms: Union[None, Unset, int]
111
+ if isinstance(self.latency_ms, Unset):
112
+ latency_ms = UNSET
113
+ else:
114
+ latency_ms = self.latency_ms
115
+
116
+ detected_tool_calls = self.detected_tool_calls
117
+
118
+ evaluation_status: Union[Unset, str] = UNSET
119
+ if not isinstance(self.evaluation_status, Unset):
120
+ evaluation_status = self.evaluation_status.value
121
+
122
+ evaluation_notes = self.evaluation_notes
123
+
124
+ evaluation_metrics = self.evaluation_metrics
125
+
126
+ agent_specific_data = self.agent_specific_data
127
+
128
+ field_dict: dict[str, Any] = {}
129
+ field_dict.update(self.additional_properties)
130
+ field_dict.update(
131
+ {
132
+ "id": id,
133
+ "run": run,
134
+ "run_id": run_id,
135
+ "prompt_name": prompt_name,
136
+ "timestamp": timestamp,
137
+ "traces": traces,
138
+ }
139
+ )
140
+ if prompt is not UNSET:
141
+ field_dict["prompt"] = prompt
142
+ if request_payload is not UNSET:
143
+ field_dict["request_payload"] = request_payload
144
+ if response_status_code is not UNSET:
145
+ field_dict["response_status_code"] = response_status_code
146
+ if response_headers is not UNSET:
147
+ field_dict["response_headers"] = response_headers
148
+ if response_body is not UNSET:
149
+ field_dict["response_body"] = response_body
150
+ if latency_ms is not UNSET:
151
+ field_dict["latency_ms"] = latency_ms
152
+ if detected_tool_calls is not UNSET:
153
+ field_dict["detected_tool_calls"] = detected_tool_calls
154
+ if evaluation_status is not UNSET:
155
+ field_dict["evaluation_status"] = evaluation_status
156
+ if evaluation_notes is not UNSET:
157
+ field_dict["evaluation_notes"] = evaluation_notes
158
+ if evaluation_metrics is not UNSET:
159
+ field_dict["evaluation_metrics"] = evaluation_metrics
160
+ if agent_specific_data is not UNSET:
161
+ field_dict["agent_specific_data"] = agent_specific_data
162
+
163
+ return field_dict
164
+
165
+ @classmethod
166
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
167
+ from ..models.trace import Trace
168
+
169
+ d = dict(src_dict)
170
+ id = UUID(d.pop("id"))
171
+
172
+ run = UUID(d.pop("run"))
173
+
174
+ run_id = UUID(d.pop("run_id"))
175
+
176
+ def _parse_prompt_name(data: object) -> Union[None, str]:
177
+ if data is None:
178
+ return data
179
+ return cast(Union[None, str], data)
180
+
181
+ prompt_name = _parse_prompt_name(d.pop("prompt_name"))
182
+
183
+ timestamp = isoparse(d.pop("timestamp"))
184
+
185
+ traces = []
186
+ _traces = d.pop("traces")
187
+ for traces_item_data in _traces:
188
+ traces_item = Trace.from_dict(traces_item_data)
189
+
190
+ traces.append(traces_item)
191
+
192
+ def _parse_prompt(data: object) -> Union[None, UUID, Unset]:
193
+ if data is None:
194
+ return data
195
+ if isinstance(data, Unset):
196
+ return data
197
+ try:
198
+ if not isinstance(data, str):
199
+ raise TypeError()
200
+ prompt_type_0 = UUID(data)
201
+
202
+ return prompt_type_0
203
+ except: # noqa: E722
204
+ pass
205
+ return cast(Union[None, UUID, Unset], data)
206
+
207
+ prompt = _parse_prompt(d.pop("prompt", UNSET))
208
+
209
+ request_payload = d.pop("request_payload", UNSET)
210
+
211
+ def _parse_response_status_code(data: object) -> Union[None, Unset, int]:
212
+ if data is None:
213
+ return data
214
+ if isinstance(data, Unset):
215
+ return data
216
+ return cast(Union[None, Unset, int], data)
217
+
218
+ response_status_code = _parse_response_status_code(
219
+ d.pop("response_status_code", UNSET)
220
+ )
221
+
222
+ response_headers = d.pop("response_headers", UNSET)
223
+
224
+ def _parse_response_body(data: object) -> Union[None, Unset, str]:
225
+ if data is None:
226
+ return data
227
+ if isinstance(data, Unset):
228
+ return data
229
+ return cast(Union[None, Unset, str], data)
230
+
231
+ response_body = _parse_response_body(d.pop("response_body", UNSET))
232
+
233
+ def _parse_latency_ms(data: object) -> Union[None, Unset, int]:
234
+ if data is None:
235
+ return data
236
+ if isinstance(data, Unset):
237
+ return data
238
+ return cast(Union[None, Unset, int], data)
239
+
240
+ latency_ms = _parse_latency_ms(d.pop("latency_ms", UNSET))
241
+
242
+ detected_tool_calls = d.pop("detected_tool_calls", UNSET)
243
+
244
+ _evaluation_status = d.pop("evaluation_status", UNSET)
245
+ evaluation_status: Union[Unset, EvaluationStatusEnum]
246
+ if isinstance(_evaluation_status, Unset):
247
+ evaluation_status = UNSET
248
+ else:
249
+ evaluation_status = EvaluationStatusEnum(_evaluation_status)
250
+
251
+ evaluation_notes = d.pop("evaluation_notes", UNSET)
252
+
253
+ evaluation_metrics = d.pop("evaluation_metrics", UNSET)
254
+
255
+ agent_specific_data = d.pop("agent_specific_data", UNSET)
256
+
257
+ result = cls(
258
+ id=id,
259
+ run=run,
260
+ run_id=run_id,
261
+ prompt_name=prompt_name,
262
+ timestamp=timestamp,
263
+ traces=traces,
264
+ prompt=prompt,
265
+ request_payload=request_payload,
266
+ response_status_code=response_status_code,
267
+ response_headers=response_headers,
268
+ response_body=response_body,
269
+ latency_ms=latency_ms,
270
+ detected_tool_calls=detected_tool_calls,
271
+ evaluation_status=evaluation_status,
272
+ evaluation_notes=evaluation_notes,
273
+ evaluation_metrics=evaluation_metrics,
274
+ agent_specific_data=agent_specific_data,
275
+ )
276
+
277
+ result.additional_properties = d
278
+ return result
279
+
280
+ @property
281
+ def additional_keys(self) -> list[str]:
282
+ return list(self.additional_properties.keys())
283
+
284
+ def __getitem__(self, key: str) -> Any:
285
+ return self.additional_properties[key]
286
+
287
+ def __setitem__(self, key: str, value: Any) -> None:
288
+ self.additional_properties[key] = value
289
+
290
+ def __delitem__(self, key: str) -> None:
291
+ del self.additional_properties[key]
292
+
293
+ def __contains__(self, key: str) -> bool:
294
+ return key in self.additional_properties
@@ -0,0 +1,14 @@
1
+ from enum import Enum
2
+
3
+
4
+ class ResultListEvaluationStatus(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)
@@ -0,0 +1,232 @@
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.evaluation_status_enum import EvaluationStatusEnum
9
+ from ..types import UNSET, Unset
10
+
11
+ T = TypeVar("T", bound="ResultRequest")
12
+
13
+
14
+ @_attrs_define
15
+ class ResultRequest:
16
+ """Serializer for the Result model, often nested in RunSerializer.
17
+
18
+ Attributes:
19
+ run (UUID):
20
+ prompt (Union[None, UUID, Unset]):
21
+ request_payload (Union[Unset, Any]): Payload sent to agent or relevant data for client-submitted results.
22
+ response_status_code (Union[None, Unset, int]):
23
+ response_headers (Union[Unset, Any]):
24
+ response_body (Union[None, Unset, str]):
25
+ latency_ms (Union[None, Unset, int]):
26
+ detected_tool_calls (Union[Unset, Any]):
27
+ evaluation_status (Union[Unset, EvaluationStatusEnum]): * `NOT_EVALUATED` - Not Evaluated
28
+ * `SUCCESSFUL_JAILBREAK` - Successful Jailbreak
29
+ * `FAILED_JAILBREAK` - Failed Jailbreak (Mitigated/Refused)
30
+ * `ERROR_AGENT_RESPONSE` - Error in Agent Response
31
+ * `ERROR_TEST_FRAMEWORK` - Error in Test Framework
32
+ * `PASSED_CRITERIA` - Passed Criteria (Not Jailbreak)
33
+ * `FAILED_CRITERIA` - Failed Criteria (Not Jailbreak)
34
+ evaluation_notes (Union[Unset, str]):
35
+ evaluation_metrics (Union[Unset, Any]):
36
+ agent_specific_data (Union[Unset, Any]):
37
+ """
38
+
39
+ run: UUID
40
+ prompt: Union[None, UUID, Unset] = UNSET
41
+ request_payload: Union[Unset, Any] = UNSET
42
+ response_status_code: Union[None, Unset, int] = UNSET
43
+ response_headers: Union[Unset, Any] = UNSET
44
+ response_body: Union[None, Unset, str] = UNSET
45
+ latency_ms: Union[None, Unset, int] = UNSET
46
+ detected_tool_calls: Union[Unset, Any] = UNSET
47
+ evaluation_status: Union[Unset, EvaluationStatusEnum] = UNSET
48
+ evaluation_notes: Union[Unset, str] = UNSET
49
+ evaluation_metrics: Union[Unset, Any] = UNSET
50
+ agent_specific_data: Union[Unset, Any] = UNSET
51
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
52
+
53
+ def to_dict(self) -> dict[str, Any]:
54
+ run = str(self.run)
55
+
56
+ prompt: Union[None, Unset, str]
57
+ if isinstance(self.prompt, Unset):
58
+ prompt = UNSET
59
+ elif isinstance(self.prompt, UUID):
60
+ prompt = str(self.prompt)
61
+ else:
62
+ prompt = self.prompt
63
+
64
+ request_payload = self.request_payload
65
+
66
+ response_status_code: Union[None, Unset, int]
67
+ if isinstance(self.response_status_code, Unset):
68
+ response_status_code = UNSET
69
+ else:
70
+ response_status_code = self.response_status_code
71
+
72
+ response_headers = self.response_headers
73
+
74
+ response_body: Union[None, Unset, str]
75
+ if isinstance(self.response_body, Unset):
76
+ response_body = UNSET
77
+ else:
78
+ response_body = self.response_body
79
+
80
+ latency_ms: Union[None, Unset, int]
81
+ if isinstance(self.latency_ms, Unset):
82
+ latency_ms = UNSET
83
+ else:
84
+ latency_ms = self.latency_ms
85
+
86
+ detected_tool_calls = self.detected_tool_calls
87
+
88
+ evaluation_status: Union[Unset, str] = UNSET
89
+ if not isinstance(self.evaluation_status, Unset):
90
+ evaluation_status = self.evaluation_status.value
91
+
92
+ evaluation_notes = self.evaluation_notes
93
+
94
+ evaluation_metrics = self.evaluation_metrics
95
+
96
+ agent_specific_data = self.agent_specific_data
97
+
98
+ field_dict: dict[str, Any] = {}
99
+ field_dict.update(self.additional_properties)
100
+ field_dict.update(
101
+ {
102
+ "run": run,
103
+ }
104
+ )
105
+ if prompt is not UNSET:
106
+ field_dict["prompt"] = prompt
107
+ if request_payload is not UNSET:
108
+ field_dict["request_payload"] = request_payload
109
+ if response_status_code is not UNSET:
110
+ field_dict["response_status_code"] = response_status_code
111
+ if response_headers is not UNSET:
112
+ field_dict["response_headers"] = response_headers
113
+ if response_body is not UNSET:
114
+ field_dict["response_body"] = response_body
115
+ if latency_ms is not UNSET:
116
+ field_dict["latency_ms"] = latency_ms
117
+ if detected_tool_calls is not UNSET:
118
+ field_dict["detected_tool_calls"] = detected_tool_calls
119
+ if evaluation_status is not UNSET:
120
+ field_dict["evaluation_status"] = evaluation_status
121
+ if evaluation_notes is not UNSET:
122
+ field_dict["evaluation_notes"] = evaluation_notes
123
+ if evaluation_metrics is not UNSET:
124
+ field_dict["evaluation_metrics"] = evaluation_metrics
125
+ if agent_specific_data is not UNSET:
126
+ field_dict["agent_specific_data"] = agent_specific_data
127
+
128
+ return field_dict
129
+
130
+ @classmethod
131
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
132
+ d = dict(src_dict)
133
+ run = UUID(d.pop("run"))
134
+
135
+ def _parse_prompt(data: object) -> Union[None, UUID, Unset]:
136
+ if data is None:
137
+ return data
138
+ if isinstance(data, Unset):
139
+ return data
140
+ try:
141
+ if not isinstance(data, str):
142
+ raise TypeError()
143
+ prompt_type_0 = UUID(data)
144
+
145
+ return prompt_type_0
146
+ except: # noqa: E722
147
+ pass
148
+ return cast(Union[None, UUID, Unset], data)
149
+
150
+ prompt = _parse_prompt(d.pop("prompt", UNSET))
151
+
152
+ request_payload = d.pop("request_payload", UNSET)
153
+
154
+ def _parse_response_status_code(data: object) -> Union[None, Unset, int]:
155
+ if data is None:
156
+ return data
157
+ if isinstance(data, Unset):
158
+ return data
159
+ return cast(Union[None, Unset, int], data)
160
+
161
+ response_status_code = _parse_response_status_code(
162
+ d.pop("response_status_code", UNSET)
163
+ )
164
+
165
+ response_headers = d.pop("response_headers", UNSET)
166
+
167
+ def _parse_response_body(data: object) -> Union[None, Unset, str]:
168
+ if data is None:
169
+ return data
170
+ if isinstance(data, Unset):
171
+ return data
172
+ return cast(Union[None, Unset, str], data)
173
+
174
+ response_body = _parse_response_body(d.pop("response_body", UNSET))
175
+
176
+ def _parse_latency_ms(data: object) -> Union[None, Unset, int]:
177
+ if data is None:
178
+ return data
179
+ if isinstance(data, Unset):
180
+ return data
181
+ return cast(Union[None, Unset, int], data)
182
+
183
+ latency_ms = _parse_latency_ms(d.pop("latency_ms", UNSET))
184
+
185
+ detected_tool_calls = d.pop("detected_tool_calls", UNSET)
186
+
187
+ _evaluation_status = d.pop("evaluation_status", UNSET)
188
+ evaluation_status: Union[Unset, EvaluationStatusEnum]
189
+ if isinstance(_evaluation_status, Unset):
190
+ evaluation_status = UNSET
191
+ else:
192
+ evaluation_status = EvaluationStatusEnum(_evaluation_status)
193
+
194
+ evaluation_notes = d.pop("evaluation_notes", UNSET)
195
+
196
+ evaluation_metrics = d.pop("evaluation_metrics", UNSET)
197
+
198
+ agent_specific_data = d.pop("agent_specific_data", UNSET)
199
+
200
+ result_request = cls(
201
+ run=run,
202
+ prompt=prompt,
203
+ request_payload=request_payload,
204
+ response_status_code=response_status_code,
205
+ response_headers=response_headers,
206
+ response_body=response_body,
207
+ latency_ms=latency_ms,
208
+ detected_tool_calls=detected_tool_calls,
209
+ evaluation_status=evaluation_status,
210
+ evaluation_notes=evaluation_notes,
211
+ evaluation_metrics=evaluation_metrics,
212
+ agent_specific_data=agent_specific_data,
213
+ )
214
+
215
+ result_request.additional_properties = d
216
+ return result_request
217
+
218
+ @property
219
+ def additional_keys(self) -> list[str]:
220
+ return list(self.additional_properties.keys())
221
+
222
+ def __getitem__(self, key: str) -> Any:
223
+ return self.additional_properties[key]
224
+
225
+ def __setitem__(self, key: str, value: Any) -> None:
226
+ self.additional_properties[key] = value
227
+
228
+ def __delitem__(self, key: str) -> None:
229
+ del self.additional_properties[key]
230
+
231
+ def __contains__(self, key: str) -> bool:
232
+ return key in self.additional_properties