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.
- hackagent/__init__.py +23 -0
- hackagent/agent.py +193 -0
- hackagent/api/__init__.py +1 -0
- hackagent/api/agent/__init__.py +1 -0
- hackagent/api/agent/agent_create.py +340 -0
- hackagent/api/agent/agent_destroy.py +136 -0
- hackagent/api/agent/agent_list.py +234 -0
- hackagent/api/agent/agent_partial_update.py +354 -0
- hackagent/api/agent/agent_retrieve.py +227 -0
- hackagent/api/agent/agent_update.py +354 -0
- hackagent/api/attack/__init__.py +1 -0
- hackagent/api/attack/attack_create.py +264 -0
- hackagent/api/attack/attack_destroy.py +140 -0
- hackagent/api/attack/attack_list.py +242 -0
- hackagent/api/attack/attack_partial_update.py +278 -0
- hackagent/api/attack/attack_retrieve.py +235 -0
- hackagent/api/attack/attack_update.py +278 -0
- hackagent/api/key/__init__.py +1 -0
- hackagent/api/key/key_create.py +168 -0
- hackagent/api/key/key_destroy.py +97 -0
- hackagent/api/key/key_list.py +158 -0
- hackagent/api/key/key_retrieve.py +150 -0
- hackagent/api/prompt/__init__.py +1 -0
- hackagent/api/prompt/prompt_create.py +160 -0
- hackagent/api/prompt/prompt_destroy.py +98 -0
- hackagent/api/prompt/prompt_list.py +173 -0
- hackagent/api/prompt/prompt_partial_update.py +174 -0
- hackagent/api/prompt/prompt_retrieve.py +151 -0
- hackagent/api/prompt/prompt_update.py +174 -0
- hackagent/api/result/__init__.py +1 -0
- hackagent/api/result/result_create.py +160 -0
- hackagent/api/result/result_destroy.py +98 -0
- hackagent/api/result/result_list.py +233 -0
- hackagent/api/result/result_partial_update.py +178 -0
- hackagent/api/result/result_retrieve.py +151 -0
- hackagent/api/result/result_trace_create.py +178 -0
- hackagent/api/result/result_update.py +174 -0
- hackagent/api/run/__init__.py +1 -0
- hackagent/api/run/run_create.py +172 -0
- hackagent/api/run/run_destroy.py +104 -0
- hackagent/api/run/run_list.py +260 -0
- hackagent/api/run/run_partial_update.py +186 -0
- hackagent/api/run/run_result_create.py +178 -0
- hackagent/api/run/run_retrieve.py +163 -0
- hackagent/api/run/run_run_tests_create.py +172 -0
- hackagent/api/run/run_update.py +186 -0
- hackagent/attacks/AdvPrefix/README.md +7 -0
- hackagent/attacks/AdvPrefix/__init__.py +0 -0
- hackagent/attacks/AdvPrefix/completer.py +438 -0
- hackagent/attacks/AdvPrefix/config.py +59 -0
- hackagent/attacks/AdvPrefix/preprocessing.py +521 -0
- hackagent/attacks/AdvPrefix/scorer.py +259 -0
- hackagent/attacks/AdvPrefix/scorer_parser.py +498 -0
- hackagent/attacks/AdvPrefix/selector.py +246 -0
- hackagent/attacks/AdvPrefix/step1_generate.py +324 -0
- hackagent/attacks/AdvPrefix/step4_compute_ce.py +293 -0
- hackagent/attacks/AdvPrefix/step6_get_completions.py +387 -0
- hackagent/attacks/AdvPrefix/step7_evaluate_responses.py +289 -0
- hackagent/attacks/AdvPrefix/step8_aggregate_evaluations.py +177 -0
- hackagent/attacks/AdvPrefix/step9_select_prefixes.py +59 -0
- hackagent/attacks/AdvPrefix/utils.py +192 -0
- hackagent/attacks/__init__.py +6 -0
- hackagent/attacks/advprefix.py +1136 -0
- hackagent/attacks/base.py +50 -0
- hackagent/attacks/strategies.py +539 -0
- hackagent/branding.py +143 -0
- hackagent/client.py +328 -0
- hackagent/errors.py +31 -0
- hackagent/logger.py +67 -0
- hackagent/models/__init__.py +71 -0
- hackagent/models/agent.py +240 -0
- hackagent/models/agent_request.py +169 -0
- hackagent/models/agent_type_enum.py +12 -0
- hackagent/models/attack.py +154 -0
- hackagent/models/attack_request.py +82 -0
- hackagent/models/evaluation_status_enum.py +14 -0
- hackagent/models/organization_minimal.py +68 -0
- hackagent/models/paginated_agent_list.py +123 -0
- hackagent/models/paginated_attack_list.py +123 -0
- hackagent/models/paginated_prompt_list.py +123 -0
- hackagent/models/paginated_result_list.py +123 -0
- hackagent/models/paginated_run_list.py +123 -0
- hackagent/models/paginated_user_api_key_list.py +123 -0
- hackagent/models/patched_agent_request.py +176 -0
- hackagent/models/patched_attack_request.py +92 -0
- hackagent/models/patched_prompt_request.py +162 -0
- hackagent/models/patched_result_request.py +237 -0
- hackagent/models/patched_run_request.py +138 -0
- hackagent/models/prompt.py +226 -0
- hackagent/models/prompt_request.py +155 -0
- hackagent/models/result.py +294 -0
- hackagent/models/result_list_evaluation_status.py +14 -0
- hackagent/models/result_request.py +232 -0
- hackagent/models/run.py +233 -0
- hackagent/models/run_list_status.py +12 -0
- hackagent/models/run_request.py +133 -0
- hackagent/models/status_enum.py +12 -0
- hackagent/models/step_type_enum.py +14 -0
- hackagent/models/trace.py +121 -0
- hackagent/models/trace_request.py +94 -0
- hackagent/models/user_api_key.py +201 -0
- hackagent/models/user_api_key_request.py +73 -0
- hackagent/models/user_profile_minimal.py +76 -0
- hackagent/py.typed +1 -0
- hackagent/router/__init__.py +11 -0
- hackagent/router/adapters/__init__.py +5 -0
- hackagent/router/adapters/google_adk.py +658 -0
- hackagent/router/adapters/litellm_adapter.py +290 -0
- hackagent/router/base.py +48 -0
- hackagent/router/router.py +753 -0
- hackagent/types.py +46 -0
- hackagent/utils.py +61 -0
- hackagent/vulnerabilities/__init__.py +0 -0
- hackagent-0.1.0.dist-info/LICENSE +202 -0
- hackagent-0.1.0.dist-info/METADATA +173 -0
- hackagent-0.1.0.dist-info/RECORD +117 -0
- hackagent-0.1.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
from collections.abc import Mapping
|
|
2
|
+
from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
|
|
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
|
+
if TYPE_CHECKING:
|
|
10
|
+
from ..models.user_api_key import UserAPIKey
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
T = TypeVar("T", bound="PaginatedUserAPIKeyList")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@_attrs_define
|
|
17
|
+
class PaginatedUserAPIKeyList:
|
|
18
|
+
"""
|
|
19
|
+
Attributes:
|
|
20
|
+
count (int): Example: 123.
|
|
21
|
+
results (list['UserAPIKey']):
|
|
22
|
+
next_ (Union[None, Unset, str]): Example: http://api.example.org/accounts/?page=4.
|
|
23
|
+
previous (Union[None, Unset, str]): Example: http://api.example.org/accounts/?page=2.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
count: int
|
|
27
|
+
results: list["UserAPIKey"]
|
|
28
|
+
next_: Union[None, Unset, str] = UNSET
|
|
29
|
+
previous: Union[None, Unset, str] = UNSET
|
|
30
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
31
|
+
|
|
32
|
+
def to_dict(self) -> dict[str, Any]:
|
|
33
|
+
count = self.count
|
|
34
|
+
|
|
35
|
+
results = []
|
|
36
|
+
for results_item_data in self.results:
|
|
37
|
+
results_item = results_item_data.to_dict()
|
|
38
|
+
results.append(results_item)
|
|
39
|
+
|
|
40
|
+
next_: Union[None, Unset, str]
|
|
41
|
+
if isinstance(self.next_, Unset):
|
|
42
|
+
next_ = UNSET
|
|
43
|
+
else:
|
|
44
|
+
next_ = self.next_
|
|
45
|
+
|
|
46
|
+
previous: Union[None, Unset, str]
|
|
47
|
+
if isinstance(self.previous, Unset):
|
|
48
|
+
previous = UNSET
|
|
49
|
+
else:
|
|
50
|
+
previous = self.previous
|
|
51
|
+
|
|
52
|
+
field_dict: dict[str, Any] = {}
|
|
53
|
+
field_dict.update(self.additional_properties)
|
|
54
|
+
field_dict.update(
|
|
55
|
+
{
|
|
56
|
+
"count": count,
|
|
57
|
+
"results": results,
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
if next_ is not UNSET:
|
|
61
|
+
field_dict["next"] = next_
|
|
62
|
+
if previous is not UNSET:
|
|
63
|
+
field_dict["previous"] = previous
|
|
64
|
+
|
|
65
|
+
return field_dict
|
|
66
|
+
|
|
67
|
+
@classmethod
|
|
68
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
69
|
+
from ..models.user_api_key import UserAPIKey
|
|
70
|
+
|
|
71
|
+
d = dict(src_dict)
|
|
72
|
+
count = d.pop("count")
|
|
73
|
+
|
|
74
|
+
results = []
|
|
75
|
+
_results = d.pop("results")
|
|
76
|
+
for results_item_data in _results:
|
|
77
|
+
results_item = UserAPIKey.from_dict(results_item_data)
|
|
78
|
+
|
|
79
|
+
results.append(results_item)
|
|
80
|
+
|
|
81
|
+
def _parse_next_(data: object) -> Union[None, Unset, str]:
|
|
82
|
+
if data is None:
|
|
83
|
+
return data
|
|
84
|
+
if isinstance(data, Unset):
|
|
85
|
+
return data
|
|
86
|
+
return cast(Union[None, Unset, str], data)
|
|
87
|
+
|
|
88
|
+
next_ = _parse_next_(d.pop("next", UNSET))
|
|
89
|
+
|
|
90
|
+
def _parse_previous(data: object) -> Union[None, Unset, str]:
|
|
91
|
+
if data is None:
|
|
92
|
+
return data
|
|
93
|
+
if isinstance(data, Unset):
|
|
94
|
+
return data
|
|
95
|
+
return cast(Union[None, Unset, str], data)
|
|
96
|
+
|
|
97
|
+
previous = _parse_previous(d.pop("previous", UNSET))
|
|
98
|
+
|
|
99
|
+
paginated_user_api_key_list = cls(
|
|
100
|
+
count=count,
|
|
101
|
+
results=results,
|
|
102
|
+
next_=next_,
|
|
103
|
+
previous=previous,
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
paginated_user_api_key_list.additional_properties = d
|
|
107
|
+
return paginated_user_api_key_list
|
|
108
|
+
|
|
109
|
+
@property
|
|
110
|
+
def additional_keys(self) -> list[str]:
|
|
111
|
+
return list(self.additional_properties.keys())
|
|
112
|
+
|
|
113
|
+
def __getitem__(self, key: str) -> Any:
|
|
114
|
+
return self.additional_properties[key]
|
|
115
|
+
|
|
116
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
117
|
+
self.additional_properties[key] = value
|
|
118
|
+
|
|
119
|
+
def __delitem__(self, key: str) -> None:
|
|
120
|
+
del self.additional_properties[key]
|
|
121
|
+
|
|
122
|
+
def __contains__(self, key: str) -> bool:
|
|
123
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,176 @@
|
|
|
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="PatchedAgentRequest")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@_attrs_define
|
|
15
|
+
class PatchedAgentRequest:
|
|
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 (Union[Unset, str]):
|
|
45
|
+
endpoint (Union[Unset, str]): The primary API endpoint URL for interacting with the agent.
|
|
46
|
+
agent_type (Union[Unset, AgentTypeEnum]): * `LITELMM` - LiteLLM
|
|
47
|
+
* `OPENAI_SDK` - OpenAI SDK/API
|
|
48
|
+
* `GOOGLE_ADK` - Google ADK
|
|
49
|
+
* `OTHER` - Other/Proprietary
|
|
50
|
+
* `UNKNOWN` - Unknown
|
|
51
|
+
description (Union[Unset, str]):
|
|
52
|
+
metadata (Union[Unset, Any]): Optional JSON data providing specific details and configuration. Structure depends
|
|
53
|
+
heavily on Agent Type. Examples:
|
|
54
|
+
- For GENERIC_ADK: {'adk_app_name': 'my_adk_app', 'protocol_version': '1.0'}
|
|
55
|
+
- For OPENAI_SDK: {'model': 'gpt-4-turbo', 'api_key_secret_name': 'MY_OPENAI_KEY', 'instructions': 'You are a
|
|
56
|
+
helpful assistant.'}
|
|
57
|
+
- For GOOGLE_ADK: {'project_id': 'my-gcp-project', 'location': 'us-central1'}
|
|
58
|
+
- General applicable: {'version': '1.2.0', 'custom_headers': {'X-Custom-Header': 'value'}}
|
|
59
|
+
organization (Union[Unset, UUID]):
|
|
60
|
+
owner (Union[None, Unset, int]):
|
|
61
|
+
"""
|
|
62
|
+
|
|
63
|
+
name: Union[Unset, str] = UNSET
|
|
64
|
+
endpoint: Union[Unset, str] = UNSET
|
|
65
|
+
agent_type: Union[Unset, AgentTypeEnum] = UNSET
|
|
66
|
+
description: Union[Unset, str] = UNSET
|
|
67
|
+
metadata: Union[Unset, Any] = UNSET
|
|
68
|
+
organization: Union[Unset, UUID] = 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
|
+
agent_type: Union[Unset, str] = UNSET
|
|
78
|
+
if not isinstance(self.agent_type, Unset):
|
|
79
|
+
agent_type = self.agent_type.value
|
|
80
|
+
|
|
81
|
+
description = self.description
|
|
82
|
+
|
|
83
|
+
metadata = self.metadata
|
|
84
|
+
|
|
85
|
+
organization: Union[Unset, str] = UNSET
|
|
86
|
+
if not isinstance(self.organization, Unset):
|
|
87
|
+
organization = str(self.organization)
|
|
88
|
+
|
|
89
|
+
owner: Union[None, Unset, int]
|
|
90
|
+
if isinstance(self.owner, Unset):
|
|
91
|
+
owner = UNSET
|
|
92
|
+
else:
|
|
93
|
+
owner = self.owner
|
|
94
|
+
|
|
95
|
+
field_dict: dict[str, Any] = {}
|
|
96
|
+
field_dict.update(self.additional_properties)
|
|
97
|
+
field_dict.update({})
|
|
98
|
+
if name is not UNSET:
|
|
99
|
+
field_dict["name"] = name
|
|
100
|
+
if endpoint is not UNSET:
|
|
101
|
+
field_dict["endpoint"] = endpoint
|
|
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 organization is not UNSET:
|
|
109
|
+
field_dict["organization"] = organization
|
|
110
|
+
if owner is not UNSET:
|
|
111
|
+
field_dict["owner"] = owner
|
|
112
|
+
|
|
113
|
+
return field_dict
|
|
114
|
+
|
|
115
|
+
@classmethod
|
|
116
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
117
|
+
d = dict(src_dict)
|
|
118
|
+
name = d.pop("name", UNSET)
|
|
119
|
+
|
|
120
|
+
endpoint = d.pop("endpoint", UNSET)
|
|
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
|
+
_organization = d.pop("organization", UNSET)
|
|
134
|
+
organization: Union[Unset, UUID]
|
|
135
|
+
if isinstance(_organization, Unset):
|
|
136
|
+
organization = UNSET
|
|
137
|
+
else:
|
|
138
|
+
organization = UUID(_organization)
|
|
139
|
+
|
|
140
|
+
def _parse_owner(data: object) -> Union[None, Unset, int]:
|
|
141
|
+
if data is None:
|
|
142
|
+
return data
|
|
143
|
+
if isinstance(data, Unset):
|
|
144
|
+
return data
|
|
145
|
+
return cast(Union[None, Unset, int], data)
|
|
146
|
+
|
|
147
|
+
owner = _parse_owner(d.pop("owner", UNSET))
|
|
148
|
+
|
|
149
|
+
patched_agent_request = cls(
|
|
150
|
+
name=name,
|
|
151
|
+
endpoint=endpoint,
|
|
152
|
+
agent_type=agent_type,
|
|
153
|
+
description=description,
|
|
154
|
+
metadata=metadata,
|
|
155
|
+
organization=organization,
|
|
156
|
+
owner=owner,
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
patched_agent_request.additional_properties = d
|
|
160
|
+
return patched_agent_request
|
|
161
|
+
|
|
162
|
+
@property
|
|
163
|
+
def additional_keys(self) -> list[str]:
|
|
164
|
+
return list(self.additional_properties.keys())
|
|
165
|
+
|
|
166
|
+
def __getitem__(self, key: str) -> Any:
|
|
167
|
+
return self.additional_properties[key]
|
|
168
|
+
|
|
169
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
170
|
+
self.additional_properties[key] = value
|
|
171
|
+
|
|
172
|
+
def __delitem__(self, key: str) -> None:
|
|
173
|
+
del self.additional_properties[key]
|
|
174
|
+
|
|
175
|
+
def __contains__(self, key: str) -> bool:
|
|
176
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
from collections.abc import Mapping
|
|
2
|
+
from typing import Any, TypeVar, Union
|
|
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="PatchedAttackRequest")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@_attrs_define
|
|
14
|
+
class PatchedAttackRequest:
|
|
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
|
+
type_ (Union[Unset, str]): A string identifier for the type of attack being configured (e.g.,
|
|
23
|
+
'PREFIX_GENERATION', 'PROMPT_INJECTION').
|
|
24
|
+
agent (Union[Unset, UUID]):
|
|
25
|
+
configuration (Union[Unset, Any]): JSON containing client-provided configuration for an attack using this
|
|
26
|
+
definition.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
type_: Union[Unset, str] = UNSET
|
|
30
|
+
agent: Union[Unset, UUID] = UNSET
|
|
31
|
+
configuration: Union[Unset, Any] = UNSET
|
|
32
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
33
|
+
|
|
34
|
+
def to_dict(self) -> dict[str, Any]:
|
|
35
|
+
type_ = self.type_
|
|
36
|
+
|
|
37
|
+
agent: Union[Unset, str] = UNSET
|
|
38
|
+
if not isinstance(self.agent, Unset):
|
|
39
|
+
agent = str(self.agent)
|
|
40
|
+
|
|
41
|
+
configuration = self.configuration
|
|
42
|
+
|
|
43
|
+
field_dict: dict[str, Any] = {}
|
|
44
|
+
field_dict.update(self.additional_properties)
|
|
45
|
+
field_dict.update({})
|
|
46
|
+
if type_ is not UNSET:
|
|
47
|
+
field_dict["type"] = type_
|
|
48
|
+
if agent is not UNSET:
|
|
49
|
+
field_dict["agent"] = agent
|
|
50
|
+
if configuration is not UNSET:
|
|
51
|
+
field_dict["configuration"] = configuration
|
|
52
|
+
|
|
53
|
+
return field_dict
|
|
54
|
+
|
|
55
|
+
@classmethod
|
|
56
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
57
|
+
d = dict(src_dict)
|
|
58
|
+
type_ = d.pop("type", UNSET)
|
|
59
|
+
|
|
60
|
+
_agent = d.pop("agent", UNSET)
|
|
61
|
+
agent: Union[Unset, UUID]
|
|
62
|
+
if isinstance(_agent, Unset):
|
|
63
|
+
agent = UNSET
|
|
64
|
+
else:
|
|
65
|
+
agent = UUID(_agent)
|
|
66
|
+
|
|
67
|
+
configuration = d.pop("configuration", UNSET)
|
|
68
|
+
|
|
69
|
+
patched_attack_request = cls(
|
|
70
|
+
type_=type_,
|
|
71
|
+
agent=agent,
|
|
72
|
+
configuration=configuration,
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
patched_attack_request.additional_properties = d
|
|
76
|
+
return patched_attack_request
|
|
77
|
+
|
|
78
|
+
@property
|
|
79
|
+
def additional_keys(self) -> list[str]:
|
|
80
|
+
return list(self.additional_properties.keys())
|
|
81
|
+
|
|
82
|
+
def __getitem__(self, key: str) -> Any:
|
|
83
|
+
return self.additional_properties[key]
|
|
84
|
+
|
|
85
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
86
|
+
self.additional_properties[key] = value
|
|
87
|
+
|
|
88
|
+
def __delitem__(self, key: str) -> None:
|
|
89
|
+
del self.additional_properties[key]
|
|
90
|
+
|
|
91
|
+
def __contains__(self, key: str) -> bool:
|
|
92
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,162 @@
|
|
|
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="PatchedPromptRequest")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@_attrs_define
|
|
14
|
+
class PatchedPromptRequest:
|
|
15
|
+
"""Serializer for the Prompt model.
|
|
16
|
+
|
|
17
|
+
Attributes:
|
|
18
|
+
name (Union[Unset, str]):
|
|
19
|
+
prompt_text (Union[Unset, str]):
|
|
20
|
+
category (Union[Unset, str]): Primary category for grouping prompts (e.g., Evasion, Harmful Content).
|
|
21
|
+
tags (Union[Unset, Any]): Optional JSON list of tags for classification (e.g., ["PII", "Malware"])
|
|
22
|
+
evaluation_criteria (Union[Unset, str]): Description of how success/failure should be judged for this specific
|
|
23
|
+
prompt.
|
|
24
|
+
expected_tool_calls (Union[Unset, Any]): JSON list of expected tool calls, e.g., [{"tool_name": "...",
|
|
25
|
+
"tool_input": {...}}]
|
|
26
|
+
expected_output_pattern (Union[Unset, str]): Optional regex pattern to match against the final response.
|
|
27
|
+
reference_output (Union[Unset, str]): Optional ideal/reference final output text.
|
|
28
|
+
organization (Union[Unset, UUID]):
|
|
29
|
+
owner (Union[None, Unset, int]):
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
name: Union[Unset, str] = UNSET
|
|
33
|
+
prompt_text: Union[Unset, str] = UNSET
|
|
34
|
+
category: Union[Unset, str] = UNSET
|
|
35
|
+
tags: Union[Unset, Any] = UNSET
|
|
36
|
+
evaluation_criteria: Union[Unset, str] = UNSET
|
|
37
|
+
expected_tool_calls: Union[Unset, Any] = UNSET
|
|
38
|
+
expected_output_pattern: Union[Unset, str] = UNSET
|
|
39
|
+
reference_output: Union[Unset, str] = UNSET
|
|
40
|
+
organization: Union[Unset, UUID] = 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
|
+
category = self.category
|
|
50
|
+
|
|
51
|
+
tags = self.tags
|
|
52
|
+
|
|
53
|
+
evaluation_criteria = self.evaluation_criteria
|
|
54
|
+
|
|
55
|
+
expected_tool_calls = self.expected_tool_calls
|
|
56
|
+
|
|
57
|
+
expected_output_pattern = self.expected_output_pattern
|
|
58
|
+
|
|
59
|
+
reference_output = self.reference_output
|
|
60
|
+
|
|
61
|
+
organization: Union[Unset, str] = UNSET
|
|
62
|
+
if not isinstance(self.organization, Unset):
|
|
63
|
+
organization = str(self.organization)
|
|
64
|
+
|
|
65
|
+
owner: Union[None, Unset, int]
|
|
66
|
+
if isinstance(self.owner, Unset):
|
|
67
|
+
owner = UNSET
|
|
68
|
+
else:
|
|
69
|
+
owner = self.owner
|
|
70
|
+
|
|
71
|
+
field_dict: dict[str, Any] = {}
|
|
72
|
+
field_dict.update(self.additional_properties)
|
|
73
|
+
field_dict.update({})
|
|
74
|
+
if name is not UNSET:
|
|
75
|
+
field_dict["name"] = name
|
|
76
|
+
if prompt_text is not UNSET:
|
|
77
|
+
field_dict["prompt_text"] = prompt_text
|
|
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 organization is not UNSET:
|
|
91
|
+
field_dict["organization"] = organization
|
|
92
|
+
if owner is not UNSET:
|
|
93
|
+
field_dict["owner"] = owner
|
|
94
|
+
|
|
95
|
+
return field_dict
|
|
96
|
+
|
|
97
|
+
@classmethod
|
|
98
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
99
|
+
d = dict(src_dict)
|
|
100
|
+
name = d.pop("name", UNSET)
|
|
101
|
+
|
|
102
|
+
prompt_text = d.pop("prompt_text", UNSET)
|
|
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
|
+
_organization = d.pop("organization", UNSET)
|
|
117
|
+
organization: Union[Unset, UUID]
|
|
118
|
+
if isinstance(_organization, Unset):
|
|
119
|
+
organization = UNSET
|
|
120
|
+
else:
|
|
121
|
+
organization = UUID(_organization)
|
|
122
|
+
|
|
123
|
+
def _parse_owner(data: object) -> Union[None, Unset, int]:
|
|
124
|
+
if data is None:
|
|
125
|
+
return data
|
|
126
|
+
if isinstance(data, Unset):
|
|
127
|
+
return data
|
|
128
|
+
return cast(Union[None, Unset, int], data)
|
|
129
|
+
|
|
130
|
+
owner = _parse_owner(d.pop("owner", UNSET))
|
|
131
|
+
|
|
132
|
+
patched_prompt_request = cls(
|
|
133
|
+
name=name,
|
|
134
|
+
prompt_text=prompt_text,
|
|
135
|
+
category=category,
|
|
136
|
+
tags=tags,
|
|
137
|
+
evaluation_criteria=evaluation_criteria,
|
|
138
|
+
expected_tool_calls=expected_tool_calls,
|
|
139
|
+
expected_output_pattern=expected_output_pattern,
|
|
140
|
+
reference_output=reference_output,
|
|
141
|
+
organization=organization,
|
|
142
|
+
owner=owner,
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
patched_prompt_request.additional_properties = d
|
|
146
|
+
return patched_prompt_request
|
|
147
|
+
|
|
148
|
+
@property
|
|
149
|
+
def additional_keys(self) -> list[str]:
|
|
150
|
+
return list(self.additional_properties.keys())
|
|
151
|
+
|
|
152
|
+
def __getitem__(self, key: str) -> Any:
|
|
153
|
+
return self.additional_properties[key]
|
|
154
|
+
|
|
155
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
156
|
+
self.additional_properties[key] = value
|
|
157
|
+
|
|
158
|
+
def __delitem__(self, key: str) -> None:
|
|
159
|
+
del self.additional_properties[key]
|
|
160
|
+
|
|
161
|
+
def __contains__(self, key: str) -> bool:
|
|
162
|
+
return key in self.additional_properties
|