hackagent 0.3.1__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 (183) hide show
  1. hackagent/__init__.py +12 -0
  2. hackagent/agent.py +214 -0
  3. hackagent/api/__init__.py +1 -0
  4. hackagent/api/agent/__init__.py +1 -0
  5. hackagent/api/agent/agent_create.py +347 -0
  6. hackagent/api/agent/agent_destroy.py +140 -0
  7. hackagent/api/agent/agent_list.py +242 -0
  8. hackagent/api/agent/agent_partial_update.py +361 -0
  9. hackagent/api/agent/agent_retrieve.py +235 -0
  10. hackagent/api/agent/agent_update.py +361 -0
  11. hackagent/api/apilogs/__init__.py +1 -0
  12. hackagent/api/apilogs/apilogs_list.py +170 -0
  13. hackagent/api/apilogs/apilogs_retrieve.py +162 -0
  14. hackagent/api/attack/__init__.py +1 -0
  15. hackagent/api/attack/attack_create.py +275 -0
  16. hackagent/api/attack/attack_destroy.py +146 -0
  17. hackagent/api/attack/attack_list.py +254 -0
  18. hackagent/api/attack/attack_partial_update.py +289 -0
  19. hackagent/api/attack/attack_retrieve.py +247 -0
  20. hackagent/api/attack/attack_update.py +289 -0
  21. hackagent/api/checkout/__init__.py +1 -0
  22. hackagent/api/checkout/checkout_create.py +225 -0
  23. hackagent/api/generate/__init__.py +1 -0
  24. hackagent/api/generate/generate_create.py +253 -0
  25. hackagent/api/judge/__init__.py +1 -0
  26. hackagent/api/judge/judge_create.py +253 -0
  27. hackagent/api/key/__init__.py +1 -0
  28. hackagent/api/key/key_create.py +179 -0
  29. hackagent/api/key/key_destroy.py +103 -0
  30. hackagent/api/key/key_list.py +170 -0
  31. hackagent/api/key/key_retrieve.py +162 -0
  32. hackagent/api/organization/__init__.py +1 -0
  33. hackagent/api/organization/organization_create.py +208 -0
  34. hackagent/api/organization/organization_destroy.py +104 -0
  35. hackagent/api/organization/organization_list.py +170 -0
  36. hackagent/api/organization/organization_me_retrieve.py +126 -0
  37. hackagent/api/organization/organization_partial_update.py +222 -0
  38. hackagent/api/organization/organization_retrieve.py +163 -0
  39. hackagent/api/organization/organization_update.py +222 -0
  40. hackagent/api/prompt/__init__.py +1 -0
  41. hackagent/api/prompt/prompt_create.py +171 -0
  42. hackagent/api/prompt/prompt_destroy.py +104 -0
  43. hackagent/api/prompt/prompt_list.py +185 -0
  44. hackagent/api/prompt/prompt_partial_update.py +185 -0
  45. hackagent/api/prompt/prompt_retrieve.py +163 -0
  46. hackagent/api/prompt/prompt_update.py +185 -0
  47. hackagent/api/result/__init__.py +1 -0
  48. hackagent/api/result/result_create.py +175 -0
  49. hackagent/api/result/result_destroy.py +106 -0
  50. hackagent/api/result/result_list.py +249 -0
  51. hackagent/api/result/result_partial_update.py +193 -0
  52. hackagent/api/result/result_retrieve.py +167 -0
  53. hackagent/api/result/result_trace_create.py +177 -0
  54. hackagent/api/result/result_update.py +189 -0
  55. hackagent/api/run/__init__.py +1 -0
  56. hackagent/api/run/run_create.py +187 -0
  57. hackagent/api/run/run_destroy.py +112 -0
  58. hackagent/api/run/run_list.py +291 -0
  59. hackagent/api/run/run_partial_update.py +201 -0
  60. hackagent/api/run/run_result_create.py +177 -0
  61. hackagent/api/run/run_retrieve.py +179 -0
  62. hackagent/api/run/run_run_tests_create.py +187 -0
  63. hackagent/api/run/run_update.py +201 -0
  64. hackagent/api/user/__init__.py +1 -0
  65. hackagent/api/user/user_create.py +212 -0
  66. hackagent/api/user/user_destroy.py +106 -0
  67. hackagent/api/user/user_list.py +174 -0
  68. hackagent/api/user/user_me_retrieve.py +126 -0
  69. hackagent/api/user/user_me_update.py +196 -0
  70. hackagent/api/user/user_partial_update.py +226 -0
  71. hackagent/api/user/user_retrieve.py +167 -0
  72. hackagent/api/user/user_update.py +226 -0
  73. hackagent/attacks/AdvPrefix/__init__.py +41 -0
  74. hackagent/attacks/AdvPrefix/completions.py +416 -0
  75. hackagent/attacks/AdvPrefix/config.py +259 -0
  76. hackagent/attacks/AdvPrefix/evaluation.py +745 -0
  77. hackagent/attacks/AdvPrefix/evaluators.py +564 -0
  78. hackagent/attacks/AdvPrefix/generate.py +711 -0
  79. hackagent/attacks/AdvPrefix/utils.py +307 -0
  80. hackagent/attacks/__init__.py +35 -0
  81. hackagent/attacks/advprefix.py +507 -0
  82. hackagent/attacks/base.py +106 -0
  83. hackagent/attacks/strategies.py +906 -0
  84. hackagent/cli/__init__.py +19 -0
  85. hackagent/cli/commands/__init__.py +20 -0
  86. hackagent/cli/commands/agent.py +100 -0
  87. hackagent/cli/commands/attack.py +417 -0
  88. hackagent/cli/commands/config.py +301 -0
  89. hackagent/cli/commands/results.py +327 -0
  90. hackagent/cli/config.py +249 -0
  91. hackagent/cli/main.py +515 -0
  92. hackagent/cli/tui/__init__.py +31 -0
  93. hackagent/cli/tui/actions_logger.py +200 -0
  94. hackagent/cli/tui/app.py +288 -0
  95. hackagent/cli/tui/base.py +137 -0
  96. hackagent/cli/tui/logger.py +318 -0
  97. hackagent/cli/tui/views/__init__.py +33 -0
  98. hackagent/cli/tui/views/agents.py +488 -0
  99. hackagent/cli/tui/views/attacks.py +624 -0
  100. hackagent/cli/tui/views/config.py +244 -0
  101. hackagent/cli/tui/views/dashboard.py +307 -0
  102. hackagent/cli/tui/views/results.py +1210 -0
  103. hackagent/cli/tui/widgets/__init__.py +24 -0
  104. hackagent/cli/tui/widgets/actions.py +346 -0
  105. hackagent/cli/tui/widgets/logs.py +435 -0
  106. hackagent/cli/utils.py +276 -0
  107. hackagent/client.py +286 -0
  108. hackagent/errors.py +37 -0
  109. hackagent/logger.py +83 -0
  110. hackagent/models/__init__.py +109 -0
  111. hackagent/models/agent.py +223 -0
  112. hackagent/models/agent_request.py +129 -0
  113. hackagent/models/api_token_log.py +184 -0
  114. hackagent/models/attack.py +154 -0
  115. hackagent/models/attack_request.py +82 -0
  116. hackagent/models/checkout_session_request_request.py +76 -0
  117. hackagent/models/checkout_session_response.py +59 -0
  118. hackagent/models/choice.py +81 -0
  119. hackagent/models/choice_message.py +67 -0
  120. hackagent/models/evaluation_status_enum.py +14 -0
  121. hackagent/models/generate_error_response.py +59 -0
  122. hackagent/models/generate_request_request.py +212 -0
  123. hackagent/models/generate_success_response.py +115 -0
  124. hackagent/models/generic_error_response.py +70 -0
  125. hackagent/models/message_request.py +67 -0
  126. hackagent/models/organization.py +102 -0
  127. hackagent/models/organization_minimal.py +68 -0
  128. hackagent/models/organization_request.py +71 -0
  129. hackagent/models/paginated_agent_list.py +123 -0
  130. hackagent/models/paginated_api_token_log_list.py +123 -0
  131. hackagent/models/paginated_attack_list.py +123 -0
  132. hackagent/models/paginated_organization_list.py +123 -0
  133. hackagent/models/paginated_prompt_list.py +123 -0
  134. hackagent/models/paginated_result_list.py +123 -0
  135. hackagent/models/paginated_run_list.py +123 -0
  136. hackagent/models/paginated_user_api_key_list.py +123 -0
  137. hackagent/models/paginated_user_profile_list.py +123 -0
  138. hackagent/models/patched_agent_request.py +128 -0
  139. hackagent/models/patched_attack_request.py +92 -0
  140. hackagent/models/patched_organization_request.py +71 -0
  141. hackagent/models/patched_prompt_request.py +125 -0
  142. hackagent/models/patched_result_request.py +237 -0
  143. hackagent/models/patched_run_request.py +138 -0
  144. hackagent/models/patched_user_profile_request.py +99 -0
  145. hackagent/models/prompt.py +220 -0
  146. hackagent/models/prompt_request.py +126 -0
  147. hackagent/models/result.py +294 -0
  148. hackagent/models/result_list_evaluation_status.py +14 -0
  149. hackagent/models/result_request.py +232 -0
  150. hackagent/models/run.py +233 -0
  151. hackagent/models/run_list_status.py +12 -0
  152. hackagent/models/run_request.py +133 -0
  153. hackagent/models/status_enum.py +12 -0
  154. hackagent/models/step_type_enum.py +14 -0
  155. hackagent/models/trace.py +121 -0
  156. hackagent/models/trace_request.py +94 -0
  157. hackagent/models/usage.py +75 -0
  158. hackagent/models/user_api_key.py +201 -0
  159. hackagent/models/user_api_key_request.py +73 -0
  160. hackagent/models/user_profile.py +135 -0
  161. hackagent/models/user_profile_minimal.py +76 -0
  162. hackagent/models/user_profile_request.py +99 -0
  163. hackagent/router/__init__.py +25 -0
  164. hackagent/router/adapters/__init__.py +20 -0
  165. hackagent/router/adapters/base.py +63 -0
  166. hackagent/router/adapters/google_adk.py +671 -0
  167. hackagent/router/adapters/litellm_adapter.py +524 -0
  168. hackagent/router/adapters/openai_adapter.py +426 -0
  169. hackagent/router/router.py +969 -0
  170. hackagent/router/types.py +54 -0
  171. hackagent/tracking/__init__.py +42 -0
  172. hackagent/tracking/context.py +163 -0
  173. hackagent/tracking/decorators.py +299 -0
  174. hackagent/tracking/tracker.py +441 -0
  175. hackagent/types.py +54 -0
  176. hackagent/utils.py +194 -0
  177. hackagent/vulnerabilities/__init__.py +13 -0
  178. hackagent/vulnerabilities/prompts.py +81 -0
  179. hackagent-0.3.1.dist-info/METADATA +122 -0
  180. hackagent-0.3.1.dist-info/RECORD +183 -0
  181. hackagent-0.3.1.dist-info/WHEEL +4 -0
  182. hackagent-0.3.1.dist-info/entry_points.txt +2 -0
  183. hackagent-0.3.1.dist-info/licenses/LICENSE +202 -0
@@ -0,0 +1,125 @@
1
+ from collections.abc import Mapping
2
+ from typing import Any, TypeVar, Union
3
+
4
+ from attrs import define as _attrs_define
5
+ from attrs import field as _attrs_field
6
+
7
+ from ..types import UNSET, Unset
8
+
9
+ T = TypeVar("T", bound="PatchedPromptRequest")
10
+
11
+
12
+ @_attrs_define
13
+ class PatchedPromptRequest:
14
+ """Serializer for the Prompt model.
15
+
16
+ Attributes:
17
+ name (Union[Unset, str]):
18
+ prompt_text (Union[Unset, str]):
19
+ category (Union[Unset, str]): Primary category for grouping prompts (e.g., Evasion, Harmful Content).
20
+ tags (Union[Unset, Any]): Optional JSON list of tags for classification (e.g., ["PII", "Malware"])
21
+ evaluation_criteria (Union[Unset, str]): Description of how success/failure should be judged for this specific
22
+ prompt.
23
+ expected_tool_calls (Union[Unset, Any]): JSON list of expected tool calls, e.g., [{"tool_name": "...",
24
+ "tool_input": {...}}]
25
+ expected_output_pattern (Union[Unset, str]): Optional regex pattern to match against the final response.
26
+ reference_output (Union[Unset, str]): Optional ideal/reference final output text.
27
+ """
28
+
29
+ name: Union[Unset, str] = UNSET
30
+ prompt_text: Union[Unset, str] = UNSET
31
+ category: Union[Unset, str] = UNSET
32
+ tags: Union[Unset, Any] = UNSET
33
+ evaluation_criteria: Union[Unset, str] = UNSET
34
+ expected_tool_calls: Union[Unset, Any] = UNSET
35
+ expected_output_pattern: Union[Unset, str] = UNSET
36
+ reference_output: Union[Unset, str] = UNSET
37
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
38
+
39
+ def to_dict(self) -> dict[str, Any]:
40
+ name = self.name
41
+
42
+ prompt_text = self.prompt_text
43
+
44
+ category = self.category
45
+
46
+ tags = self.tags
47
+
48
+ evaluation_criteria = self.evaluation_criteria
49
+
50
+ expected_tool_calls = self.expected_tool_calls
51
+
52
+ expected_output_pattern = self.expected_output_pattern
53
+
54
+ reference_output = self.reference_output
55
+
56
+ field_dict: dict[str, Any] = {}
57
+ field_dict.update(self.additional_properties)
58
+ field_dict.update({})
59
+ if name is not UNSET:
60
+ field_dict["name"] = name
61
+ if prompt_text is not UNSET:
62
+ field_dict["prompt_text"] = prompt_text
63
+ if category is not UNSET:
64
+ field_dict["category"] = category
65
+ if tags is not UNSET:
66
+ field_dict["tags"] = tags
67
+ if evaluation_criteria is not UNSET:
68
+ field_dict["evaluation_criteria"] = evaluation_criteria
69
+ if expected_tool_calls is not UNSET:
70
+ field_dict["expected_tool_calls"] = expected_tool_calls
71
+ if expected_output_pattern is not UNSET:
72
+ field_dict["expected_output_pattern"] = expected_output_pattern
73
+ if reference_output is not UNSET:
74
+ field_dict["reference_output"] = reference_output
75
+
76
+ return field_dict
77
+
78
+ @classmethod
79
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
80
+ d = dict(src_dict)
81
+ name = d.pop("name", UNSET)
82
+
83
+ prompt_text = d.pop("prompt_text", UNSET)
84
+
85
+ category = d.pop("category", UNSET)
86
+
87
+ tags = d.pop("tags", UNSET)
88
+
89
+ evaluation_criteria = d.pop("evaluation_criteria", UNSET)
90
+
91
+ expected_tool_calls = d.pop("expected_tool_calls", UNSET)
92
+
93
+ expected_output_pattern = d.pop("expected_output_pattern", UNSET)
94
+
95
+ reference_output = d.pop("reference_output", UNSET)
96
+
97
+ patched_prompt_request = cls(
98
+ name=name,
99
+ prompt_text=prompt_text,
100
+ category=category,
101
+ tags=tags,
102
+ evaluation_criteria=evaluation_criteria,
103
+ expected_tool_calls=expected_tool_calls,
104
+ expected_output_pattern=expected_output_pattern,
105
+ reference_output=reference_output,
106
+ )
107
+
108
+ patched_prompt_request.additional_properties = d
109
+ return patched_prompt_request
110
+
111
+ @property
112
+ def additional_keys(self) -> list[str]:
113
+ return list(self.additional_properties.keys())
114
+
115
+ def __getitem__(self, key: str) -> Any:
116
+ return self.additional_properties[key]
117
+
118
+ def __setitem__(self, key: str, value: Any) -> None:
119
+ self.additional_properties[key] = value
120
+
121
+ def __delitem__(self, key: str) -> None:
122
+ del self.additional_properties[key]
123
+
124
+ def __contains__(self, key: str) -> bool:
125
+ return key in self.additional_properties
@@ -0,0 +1,237 @@
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="PatchedResultRequest")
12
+
13
+
14
+ @_attrs_define
15
+ class PatchedResultRequest:
16
+ """Serializer for the Result model, often nested in RunSerializer.
17
+
18
+ Attributes:
19
+ run (Union[Unset, 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: Union[Unset, UUID] = UNSET
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: Union[Unset, str] = UNSET
55
+ if not isinstance(self.run, Unset):
56
+ run = str(self.run)
57
+
58
+ prompt: Union[None, Unset, str]
59
+ if isinstance(self.prompt, Unset):
60
+ prompt = UNSET
61
+ elif isinstance(self.prompt, UUID):
62
+ prompt = str(self.prompt)
63
+ else:
64
+ prompt = self.prompt
65
+
66
+ request_payload = self.request_payload
67
+
68
+ response_status_code: Union[None, Unset, int]
69
+ if isinstance(self.response_status_code, Unset):
70
+ response_status_code = UNSET
71
+ else:
72
+ response_status_code = self.response_status_code
73
+
74
+ response_headers = self.response_headers
75
+
76
+ response_body: Union[None, Unset, str]
77
+ if isinstance(self.response_body, Unset):
78
+ response_body = UNSET
79
+ else:
80
+ response_body = self.response_body
81
+
82
+ latency_ms: Union[None, Unset, int]
83
+ if isinstance(self.latency_ms, Unset):
84
+ latency_ms = UNSET
85
+ else:
86
+ latency_ms = self.latency_ms
87
+
88
+ detected_tool_calls = self.detected_tool_calls
89
+
90
+ evaluation_status: Union[Unset, str] = UNSET
91
+ if not isinstance(self.evaluation_status, Unset):
92
+ evaluation_status = self.evaluation_status.value
93
+
94
+ evaluation_notes = self.evaluation_notes
95
+
96
+ evaluation_metrics = self.evaluation_metrics
97
+
98
+ agent_specific_data = self.agent_specific_data
99
+
100
+ field_dict: dict[str, Any] = {}
101
+ field_dict.update(self.additional_properties)
102
+ field_dict.update({})
103
+ if run is not UNSET:
104
+ field_dict["run"] = run
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 = d.pop("run", UNSET)
134
+ run: Union[Unset, UUID]
135
+ if isinstance(_run, Unset):
136
+ run = UNSET
137
+ else:
138
+ run = UUID(_run)
139
+
140
+ def _parse_prompt(data: object) -> Union[None, UUID, Unset]:
141
+ if data is None:
142
+ return data
143
+ if isinstance(data, Unset):
144
+ return data
145
+ try:
146
+ if not isinstance(data, str):
147
+ raise TypeError()
148
+ prompt_type_0 = UUID(data)
149
+
150
+ return prompt_type_0
151
+ except: # noqa: E722
152
+ pass
153
+ return cast(Union[None, UUID, Unset], data)
154
+
155
+ prompt = _parse_prompt(d.pop("prompt", UNSET))
156
+
157
+ request_payload = d.pop("request_payload", UNSET)
158
+
159
+ def _parse_response_status_code(data: object) -> Union[None, Unset, int]:
160
+ if data is None:
161
+ return data
162
+ if isinstance(data, Unset):
163
+ return data
164
+ return cast(Union[None, Unset, int], data)
165
+
166
+ response_status_code = _parse_response_status_code(
167
+ d.pop("response_status_code", UNSET)
168
+ )
169
+
170
+ response_headers = d.pop("response_headers", UNSET)
171
+
172
+ def _parse_response_body(data: object) -> Union[None, Unset, str]:
173
+ if data is None:
174
+ return data
175
+ if isinstance(data, Unset):
176
+ return data
177
+ return cast(Union[None, Unset, str], data)
178
+
179
+ response_body = _parse_response_body(d.pop("response_body", UNSET))
180
+
181
+ def _parse_latency_ms(data: object) -> Union[None, Unset, int]:
182
+ if data is None:
183
+ return data
184
+ if isinstance(data, Unset):
185
+ return data
186
+ return cast(Union[None, Unset, int], data)
187
+
188
+ latency_ms = _parse_latency_ms(d.pop("latency_ms", UNSET))
189
+
190
+ detected_tool_calls = d.pop("detected_tool_calls", UNSET)
191
+
192
+ _evaluation_status = d.pop("evaluation_status", UNSET)
193
+ evaluation_status: Union[Unset, EvaluationStatusEnum]
194
+ if isinstance(_evaluation_status, Unset):
195
+ evaluation_status = UNSET
196
+ else:
197
+ evaluation_status = EvaluationStatusEnum(_evaluation_status)
198
+
199
+ evaluation_notes = d.pop("evaluation_notes", UNSET)
200
+
201
+ evaluation_metrics = d.pop("evaluation_metrics", UNSET)
202
+
203
+ agent_specific_data = d.pop("agent_specific_data", UNSET)
204
+
205
+ patched_result_request = cls(
206
+ run=run,
207
+ prompt=prompt,
208
+ request_payload=request_payload,
209
+ response_status_code=response_status_code,
210
+ response_headers=response_headers,
211
+ response_body=response_body,
212
+ latency_ms=latency_ms,
213
+ detected_tool_calls=detected_tool_calls,
214
+ evaluation_status=evaluation_status,
215
+ evaluation_notes=evaluation_notes,
216
+ evaluation_metrics=evaluation_metrics,
217
+ agent_specific_data=agent_specific_data,
218
+ )
219
+
220
+ patched_result_request.additional_properties = d
221
+ return patched_result_request
222
+
223
+ @property
224
+ def additional_keys(self) -> list[str]:
225
+ return list(self.additional_properties.keys())
226
+
227
+ def __getitem__(self, key: str) -> Any:
228
+ return self.additional_properties[key]
229
+
230
+ def __setitem__(self, key: str, value: Any) -> None:
231
+ self.additional_properties[key] = value
232
+
233
+ def __delitem__(self, key: str) -> None:
234
+ del self.additional_properties[key]
235
+
236
+ def __contains__(self, key: str) -> bool:
237
+ return key in self.additional_properties
@@ -0,0 +1,138 @@
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.status_enum import StatusEnum
9
+ from ..types import UNSET, Unset
10
+
11
+ T = TypeVar("T", bound="PatchedRunRequest")
12
+
13
+
14
+ @_attrs_define
15
+ class PatchedRunRequest:
16
+ """Serializer for the Run model, used for both input and output.
17
+
18
+ Attributes:
19
+ agent (Union[Unset, UUID]):
20
+ attack (Union[None, UUID, Unset]): The Attack this run is an instance of, if applicable.
21
+ run_config (Union[Unset, Any]): JSON containing specific settings for this run. If linked to an Attack, this
22
+ might be a copy or subset of its configuration.
23
+ status (Union[Unset, StatusEnum]): * `PENDING` - Pending
24
+ * `RUNNING` - Running
25
+ * `COMPLETED` - Completed
26
+ * `FAILED` - Failed
27
+ * `CANCELLED` - Cancelled
28
+ run_notes (Union[Unset, str]):
29
+ """
30
+
31
+ agent: Union[Unset, UUID] = UNSET
32
+ attack: Union[None, UUID, Unset] = UNSET
33
+ run_config: Union[Unset, Any] = UNSET
34
+ status: Union[Unset, StatusEnum] = UNSET
35
+ run_notes: Union[Unset, str] = UNSET
36
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
37
+
38
+ def to_dict(self) -> dict[str, Any]:
39
+ agent: Union[Unset, str] = UNSET
40
+ if not isinstance(self.agent, Unset):
41
+ agent = str(self.agent)
42
+
43
+ attack: Union[None, Unset, str]
44
+ if isinstance(self.attack, Unset):
45
+ attack = UNSET
46
+ elif isinstance(self.attack, UUID):
47
+ attack = str(self.attack)
48
+ else:
49
+ attack = self.attack
50
+
51
+ run_config = self.run_config
52
+
53
+ status: Union[Unset, str] = UNSET
54
+ if not isinstance(self.status, Unset):
55
+ status = self.status.value
56
+
57
+ run_notes = self.run_notes
58
+
59
+ field_dict: dict[str, Any] = {}
60
+ field_dict.update(self.additional_properties)
61
+ field_dict.update({})
62
+ if agent is not UNSET:
63
+ field_dict["agent"] = agent
64
+ if attack is not UNSET:
65
+ field_dict["attack"] = attack
66
+ if run_config is not UNSET:
67
+ field_dict["run_config"] = run_config
68
+ if status is not UNSET:
69
+ field_dict["status"] = status
70
+ if run_notes is not UNSET:
71
+ field_dict["run_notes"] = run_notes
72
+
73
+ return field_dict
74
+
75
+ @classmethod
76
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
77
+ d = dict(src_dict)
78
+ _agent = d.pop("agent", UNSET)
79
+ agent: Union[Unset, UUID]
80
+ if isinstance(_agent, Unset):
81
+ agent = UNSET
82
+ else:
83
+ agent = UUID(_agent)
84
+
85
+ def _parse_attack(data: object) -> Union[None, UUID, Unset]:
86
+ if data is None:
87
+ return data
88
+ if isinstance(data, Unset):
89
+ return data
90
+ try:
91
+ if not isinstance(data, str):
92
+ raise TypeError()
93
+ attack_type_0 = UUID(data)
94
+
95
+ return attack_type_0
96
+ except: # noqa: E722
97
+ pass
98
+ return cast(Union[None, UUID, Unset], data)
99
+
100
+ attack = _parse_attack(d.pop("attack", UNSET))
101
+
102
+ run_config = d.pop("run_config", UNSET)
103
+
104
+ _status = d.pop("status", UNSET)
105
+ status: Union[Unset, StatusEnum]
106
+ if isinstance(_status, Unset):
107
+ status = UNSET
108
+ else:
109
+ status = StatusEnum(_status)
110
+
111
+ run_notes = d.pop("run_notes", UNSET)
112
+
113
+ patched_run_request = cls(
114
+ agent=agent,
115
+ attack=attack,
116
+ run_config=run_config,
117
+ status=status,
118
+ run_notes=run_notes,
119
+ )
120
+
121
+ patched_run_request.additional_properties = d
122
+ return patched_run_request
123
+
124
+ @property
125
+ def additional_keys(self) -> list[str]:
126
+ return list(self.additional_properties.keys())
127
+
128
+ def __getitem__(self, key: str) -> Any:
129
+ return self.additional_properties[key]
130
+
131
+ def __setitem__(self, key: str, value: Any) -> None:
132
+ self.additional_properties[key] = value
133
+
134
+ def __delitem__(self, key: str) -> None:
135
+ del self.additional_properties[key]
136
+
137
+ def __contains__(self, key: str) -> bool:
138
+ return key in self.additional_properties
@@ -0,0 +1,99 @@
1
+ from collections.abc import Mapping
2
+ from typing import Any, TypeVar, Union
3
+
4
+ from attrs import define as _attrs_define
5
+ from attrs import field as _attrs_field
6
+
7
+ from .. import types
8
+ from ..types import UNSET, Unset
9
+
10
+ T = TypeVar("T", bound="PatchedUserProfileRequest")
11
+
12
+
13
+ @_attrs_define
14
+ class PatchedUserProfileRequest:
15
+ """
16
+ Attributes:
17
+ email (Union[Unset, str]):
18
+ first_name (Union[Unset, str]):
19
+ last_name (Union[Unset, str]):
20
+ """
21
+
22
+ email: Union[Unset, str] = UNSET
23
+ first_name: Union[Unset, str] = UNSET
24
+ last_name: Union[Unset, str] = UNSET
25
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
26
+
27
+ def to_dict(self) -> dict[str, Any]:
28
+ email = self.email
29
+
30
+ first_name = self.first_name
31
+
32
+ last_name = self.last_name
33
+
34
+ field_dict: dict[str, Any] = {}
35
+ field_dict.update(self.additional_properties)
36
+ field_dict.update({})
37
+ if email is not UNSET:
38
+ field_dict["email"] = email
39
+ if first_name is not UNSET:
40
+ field_dict["first_name"] = first_name
41
+ if last_name is not UNSET:
42
+ field_dict["last_name"] = last_name
43
+
44
+ return field_dict
45
+
46
+ def to_multipart(self) -> types.RequestFiles:
47
+ files: types.RequestFiles = []
48
+
49
+ if not isinstance(self.email, Unset):
50
+ files.append(("email", (None, str(self.email).encode(), "text/plain")))
51
+
52
+ if not isinstance(self.first_name, Unset):
53
+ files.append(
54
+ ("first_name", (None, str(self.first_name).encode(), "text/plain"))
55
+ )
56
+
57
+ if not isinstance(self.last_name, Unset):
58
+ files.append(
59
+ ("last_name", (None, str(self.last_name).encode(), "text/plain"))
60
+ )
61
+
62
+ for prop_name, prop in self.additional_properties.items():
63
+ files.append((prop_name, (None, str(prop).encode(), "text/plain")))
64
+
65
+ return files
66
+
67
+ @classmethod
68
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
69
+ d = dict(src_dict)
70
+ email = d.pop("email", UNSET)
71
+
72
+ first_name = d.pop("first_name", UNSET)
73
+
74
+ last_name = d.pop("last_name", UNSET)
75
+
76
+ patched_user_profile_request = cls(
77
+ email=email,
78
+ first_name=first_name,
79
+ last_name=last_name,
80
+ )
81
+
82
+ patched_user_profile_request.additional_properties = d
83
+ return patched_user_profile_request
84
+
85
+ @property
86
+ def additional_keys(self) -> list[str]:
87
+ return list(self.additional_properties.keys())
88
+
89
+ def __getitem__(self, key: str) -> Any:
90
+ return self.additional_properties[key]
91
+
92
+ def __setitem__(self, key: str, value: Any) -> None:
93
+ self.additional_properties[key] = value
94
+
95
+ def __delitem__(self, key: str) -> None:
96
+ del self.additional_properties[key]
97
+
98
+ def __contains__(self, key: str) -> bool:
99
+ return key in self.additional_properties