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.
- hackagent/__init__.py +12 -0
- hackagent/agent.py +214 -0
- hackagent/api/__init__.py +1 -0
- hackagent/api/agent/__init__.py +1 -0
- hackagent/api/agent/agent_create.py +347 -0
- hackagent/api/agent/agent_destroy.py +140 -0
- hackagent/api/agent/agent_list.py +242 -0
- hackagent/api/agent/agent_partial_update.py +361 -0
- hackagent/api/agent/agent_retrieve.py +235 -0
- hackagent/api/agent/agent_update.py +361 -0
- hackagent/api/apilogs/__init__.py +1 -0
- hackagent/api/apilogs/apilogs_list.py +170 -0
- hackagent/api/apilogs/apilogs_retrieve.py +162 -0
- hackagent/api/attack/__init__.py +1 -0
- hackagent/api/attack/attack_create.py +275 -0
- hackagent/api/attack/attack_destroy.py +146 -0
- hackagent/api/attack/attack_list.py +254 -0
- hackagent/api/attack/attack_partial_update.py +289 -0
- hackagent/api/attack/attack_retrieve.py +247 -0
- hackagent/api/attack/attack_update.py +289 -0
- hackagent/api/checkout/__init__.py +1 -0
- hackagent/api/checkout/checkout_create.py +225 -0
- hackagent/api/generate/__init__.py +1 -0
- hackagent/api/generate/generate_create.py +253 -0
- hackagent/api/judge/__init__.py +1 -0
- hackagent/api/judge/judge_create.py +253 -0
- hackagent/api/key/__init__.py +1 -0
- hackagent/api/key/key_create.py +179 -0
- hackagent/api/key/key_destroy.py +103 -0
- hackagent/api/key/key_list.py +170 -0
- hackagent/api/key/key_retrieve.py +162 -0
- hackagent/api/organization/__init__.py +1 -0
- hackagent/api/organization/organization_create.py +208 -0
- hackagent/api/organization/organization_destroy.py +104 -0
- hackagent/api/organization/organization_list.py +170 -0
- hackagent/api/organization/organization_me_retrieve.py +126 -0
- hackagent/api/organization/organization_partial_update.py +222 -0
- hackagent/api/organization/organization_retrieve.py +163 -0
- hackagent/api/organization/organization_update.py +222 -0
- hackagent/api/prompt/__init__.py +1 -0
- hackagent/api/prompt/prompt_create.py +171 -0
- hackagent/api/prompt/prompt_destroy.py +104 -0
- hackagent/api/prompt/prompt_list.py +185 -0
- hackagent/api/prompt/prompt_partial_update.py +185 -0
- hackagent/api/prompt/prompt_retrieve.py +163 -0
- hackagent/api/prompt/prompt_update.py +185 -0
- hackagent/api/result/__init__.py +1 -0
- hackagent/api/result/result_create.py +175 -0
- hackagent/api/result/result_destroy.py +106 -0
- hackagent/api/result/result_list.py +249 -0
- hackagent/api/result/result_partial_update.py +193 -0
- hackagent/api/result/result_retrieve.py +167 -0
- hackagent/api/result/result_trace_create.py +177 -0
- hackagent/api/result/result_update.py +189 -0
- hackagent/api/run/__init__.py +1 -0
- hackagent/api/run/run_create.py +187 -0
- hackagent/api/run/run_destroy.py +112 -0
- hackagent/api/run/run_list.py +291 -0
- hackagent/api/run/run_partial_update.py +201 -0
- hackagent/api/run/run_result_create.py +177 -0
- hackagent/api/run/run_retrieve.py +179 -0
- hackagent/api/run/run_run_tests_create.py +187 -0
- hackagent/api/run/run_update.py +201 -0
- hackagent/api/user/__init__.py +1 -0
- hackagent/api/user/user_create.py +212 -0
- hackagent/api/user/user_destroy.py +106 -0
- hackagent/api/user/user_list.py +174 -0
- hackagent/api/user/user_me_retrieve.py +126 -0
- hackagent/api/user/user_me_update.py +196 -0
- hackagent/api/user/user_partial_update.py +226 -0
- hackagent/api/user/user_retrieve.py +167 -0
- hackagent/api/user/user_update.py +226 -0
- hackagent/attacks/AdvPrefix/__init__.py +41 -0
- hackagent/attacks/AdvPrefix/completions.py +416 -0
- hackagent/attacks/AdvPrefix/config.py +259 -0
- hackagent/attacks/AdvPrefix/evaluation.py +745 -0
- hackagent/attacks/AdvPrefix/evaluators.py +564 -0
- hackagent/attacks/AdvPrefix/generate.py +711 -0
- hackagent/attacks/AdvPrefix/utils.py +307 -0
- hackagent/attacks/__init__.py +35 -0
- hackagent/attacks/advprefix.py +507 -0
- hackagent/attacks/base.py +106 -0
- hackagent/attacks/strategies.py +906 -0
- hackagent/cli/__init__.py +19 -0
- hackagent/cli/commands/__init__.py +20 -0
- hackagent/cli/commands/agent.py +100 -0
- hackagent/cli/commands/attack.py +417 -0
- hackagent/cli/commands/config.py +301 -0
- hackagent/cli/commands/results.py +327 -0
- hackagent/cli/config.py +249 -0
- hackagent/cli/main.py +515 -0
- hackagent/cli/tui/__init__.py +31 -0
- hackagent/cli/tui/actions_logger.py +200 -0
- hackagent/cli/tui/app.py +288 -0
- hackagent/cli/tui/base.py +137 -0
- hackagent/cli/tui/logger.py +318 -0
- hackagent/cli/tui/views/__init__.py +33 -0
- hackagent/cli/tui/views/agents.py +488 -0
- hackagent/cli/tui/views/attacks.py +624 -0
- hackagent/cli/tui/views/config.py +244 -0
- hackagent/cli/tui/views/dashboard.py +307 -0
- hackagent/cli/tui/views/results.py +1210 -0
- hackagent/cli/tui/widgets/__init__.py +24 -0
- hackagent/cli/tui/widgets/actions.py +346 -0
- hackagent/cli/tui/widgets/logs.py +435 -0
- hackagent/cli/utils.py +276 -0
- hackagent/client.py +286 -0
- hackagent/errors.py +37 -0
- hackagent/logger.py +83 -0
- hackagent/models/__init__.py +109 -0
- hackagent/models/agent.py +223 -0
- hackagent/models/agent_request.py +129 -0
- hackagent/models/api_token_log.py +184 -0
- hackagent/models/attack.py +154 -0
- hackagent/models/attack_request.py +82 -0
- hackagent/models/checkout_session_request_request.py +76 -0
- hackagent/models/checkout_session_response.py +59 -0
- hackagent/models/choice.py +81 -0
- hackagent/models/choice_message.py +67 -0
- hackagent/models/evaluation_status_enum.py +14 -0
- hackagent/models/generate_error_response.py +59 -0
- hackagent/models/generate_request_request.py +212 -0
- hackagent/models/generate_success_response.py +115 -0
- hackagent/models/generic_error_response.py +70 -0
- hackagent/models/message_request.py +67 -0
- hackagent/models/organization.py +102 -0
- hackagent/models/organization_minimal.py +68 -0
- hackagent/models/organization_request.py +71 -0
- hackagent/models/paginated_agent_list.py +123 -0
- hackagent/models/paginated_api_token_log_list.py +123 -0
- hackagent/models/paginated_attack_list.py +123 -0
- hackagent/models/paginated_organization_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/paginated_user_profile_list.py +123 -0
- hackagent/models/patched_agent_request.py +128 -0
- hackagent/models/patched_attack_request.py +92 -0
- hackagent/models/patched_organization_request.py +71 -0
- hackagent/models/patched_prompt_request.py +125 -0
- hackagent/models/patched_result_request.py +237 -0
- hackagent/models/patched_run_request.py +138 -0
- hackagent/models/patched_user_profile_request.py +99 -0
- hackagent/models/prompt.py +220 -0
- hackagent/models/prompt_request.py +126 -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/usage.py +75 -0
- hackagent/models/user_api_key.py +201 -0
- hackagent/models/user_api_key_request.py +73 -0
- hackagent/models/user_profile.py +135 -0
- hackagent/models/user_profile_minimal.py +76 -0
- hackagent/models/user_profile_request.py +99 -0
- hackagent/router/__init__.py +25 -0
- hackagent/router/adapters/__init__.py +20 -0
- hackagent/router/adapters/base.py +63 -0
- hackagent/router/adapters/google_adk.py +671 -0
- hackagent/router/adapters/litellm_adapter.py +524 -0
- hackagent/router/adapters/openai_adapter.py +426 -0
- hackagent/router/router.py +969 -0
- hackagent/router/types.py +54 -0
- hackagent/tracking/__init__.py +42 -0
- hackagent/tracking/context.py +163 -0
- hackagent/tracking/decorators.py +299 -0
- hackagent/tracking/tracker.py +441 -0
- hackagent/types.py +54 -0
- hackagent/utils.py +194 -0
- hackagent/vulnerabilities/__init__.py +13 -0
- hackagent/vulnerabilities/prompts.py +81 -0
- hackagent-0.3.1.dist-info/METADATA +122 -0
- hackagent-0.3.1.dist-info/RECORD +183 -0
- hackagent-0.3.1.dist-info/WHEEL +4 -0
- hackagent-0.3.1.dist-info/entry_points.txt +2 -0
- hackagent-0.3.1.dist-info/licenses/LICENSE +202 -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.run import Run
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
T = TypeVar("T", bound="PaginatedRunList")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@_attrs_define
|
|
17
|
+
class PaginatedRunList:
|
|
18
|
+
"""
|
|
19
|
+
Attributes:
|
|
20
|
+
count (int): Example: 123.
|
|
21
|
+
results (list['Run']):
|
|
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["Run"]
|
|
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.run import Run
|
|
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 = Run.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_run_list = cls(
|
|
100
|
+
count=count,
|
|
101
|
+
results=results,
|
|
102
|
+
next_=next_,
|
|
103
|
+
previous=previous,
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
paginated_run_list.additional_properties = d
|
|
107
|
+
return paginated_run_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,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,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_profile import UserProfile
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
T = TypeVar("T", bound="PaginatedUserProfileList")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@_attrs_define
|
|
17
|
+
class PaginatedUserProfileList:
|
|
18
|
+
"""
|
|
19
|
+
Attributes:
|
|
20
|
+
count (int): Example: 123.
|
|
21
|
+
results (list['UserProfile']):
|
|
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["UserProfile"]
|
|
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_profile import UserProfile
|
|
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 = UserProfile.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_profile_list = cls(
|
|
100
|
+
count=count,
|
|
101
|
+
results=results,
|
|
102
|
+
next_=next_,
|
|
103
|
+
previous=previous,
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
paginated_user_profile_list.additional_properties = d
|
|
107
|
+
return paginated_user_profile_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,128 @@
|
|
|
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="PatchedAgentRequest")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@_attrs_define
|
|
13
|
+
class PatchedAgentRequest:
|
|
14
|
+
"""Serializes Agent model instances to JSON and validates data for creating
|
|
15
|
+
or updating Agent instances.
|
|
16
|
+
|
|
17
|
+
This serializer provides a comprehensive representation of an Agent,
|
|
18
|
+
including its type, endpoint, and nested details for related 'organization'
|
|
19
|
+
and 'owner' for read operations, while allowing 'organization' and 'owner' IDs
|
|
20
|
+
for write operations.
|
|
21
|
+
|
|
22
|
+
Attributes:
|
|
23
|
+
organization_detail (OrganizationMinimalSerializer): Read-only nested
|
|
24
|
+
serializer for the agent's organization. Displays minimal details.
|
|
25
|
+
owner_detail (UserProfileMinimalSerializer): Read-only nested serializer
|
|
26
|
+
for the agent's owner's user profile. Displays minimal details.
|
|
27
|
+
Can be null if the agent has no owner or the owner has no profile.
|
|
28
|
+
agent_type (CharField): The type of the agent as a string
|
|
29
|
+
(e.g., LITELLM, OPENAI_SDK, GOOGLE_ADK).
|
|
30
|
+
|
|
31
|
+
Meta:
|
|
32
|
+
model (Agent): The model class that this serializer works with.
|
|
33
|
+
fields (tuple): The fields to include in the serialized output.
|
|
34
|
+
Includes standard Agent fields like 'endpoint', 'type',
|
|
35
|
+
and the read-only nested details.
|
|
36
|
+
read_only_fields (tuple): Fields that are read-only and cannot be
|
|
37
|
+
set during create/update operations through this serializer.
|
|
38
|
+
This includes 'id', 'created_at', 'updated_at', and the
|
|
39
|
+
nested detail fields.
|
|
40
|
+
|
|
41
|
+
Attributes:
|
|
42
|
+
name (Union[Unset, str]):
|
|
43
|
+
endpoint (Union[Unset, str]): The primary API endpoint URL for interacting with the agent.
|
|
44
|
+
agent_type (Union[Unset, str]): The specific SDK, ADK, or API type the agent is built upon (e.g., OpenAI SDK,
|
|
45
|
+
Generic ADK).
|
|
46
|
+
description (Union[Unset, str]):
|
|
47
|
+
metadata (Union[Unset, Any]): Optional JSON data providing specific details and configuration. Structure depends
|
|
48
|
+
heavily on Agent Type. Examples:
|
|
49
|
+
- For GENERIC_ADK: {'adk_app_name': 'my_adk_app', 'protocol_version': '1.0'}
|
|
50
|
+
- For OPENAI_SDK: {'model': 'gpt-4-turbo', 'api_key_secret_name': 'MY_OPENAI_KEY', 'instructions': 'You are a
|
|
51
|
+
helpful assistant.'}
|
|
52
|
+
- For GOOGLE_ADK: {'project_id': 'my-gcp-project', 'location': 'us-central1'}
|
|
53
|
+
- General applicable: {'version': '1.2.0', 'custom_headers': {'X-Custom-Header': 'value'}}
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
name: Union[Unset, str] = UNSET
|
|
57
|
+
endpoint: Union[Unset, str] = UNSET
|
|
58
|
+
agent_type: Union[Unset, str] = UNSET
|
|
59
|
+
description: Union[Unset, str] = UNSET
|
|
60
|
+
metadata: Union[Unset, Any] = UNSET
|
|
61
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
62
|
+
|
|
63
|
+
def to_dict(self) -> dict[str, Any]:
|
|
64
|
+
name = self.name
|
|
65
|
+
|
|
66
|
+
endpoint = self.endpoint
|
|
67
|
+
|
|
68
|
+
agent_type = self.agent_type
|
|
69
|
+
|
|
70
|
+
description = self.description
|
|
71
|
+
|
|
72
|
+
metadata = self.metadata
|
|
73
|
+
|
|
74
|
+
field_dict: dict[str, Any] = {}
|
|
75
|
+
field_dict.update(self.additional_properties)
|
|
76
|
+
field_dict.update({})
|
|
77
|
+
if name is not UNSET:
|
|
78
|
+
field_dict["name"] = name
|
|
79
|
+
if endpoint is not UNSET:
|
|
80
|
+
field_dict["endpoint"] = endpoint
|
|
81
|
+
if agent_type is not UNSET:
|
|
82
|
+
field_dict["agent_type"] = agent_type
|
|
83
|
+
if description is not UNSET:
|
|
84
|
+
field_dict["description"] = description
|
|
85
|
+
if metadata is not UNSET:
|
|
86
|
+
field_dict["metadata"] = metadata
|
|
87
|
+
|
|
88
|
+
return field_dict
|
|
89
|
+
|
|
90
|
+
@classmethod
|
|
91
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
92
|
+
d = dict(src_dict)
|
|
93
|
+
name = d.pop("name", UNSET)
|
|
94
|
+
|
|
95
|
+
endpoint = d.pop("endpoint", UNSET)
|
|
96
|
+
|
|
97
|
+
agent_type = d.pop("agent_type", UNSET)
|
|
98
|
+
|
|
99
|
+
description = d.pop("description", UNSET)
|
|
100
|
+
|
|
101
|
+
metadata = d.pop("metadata", UNSET)
|
|
102
|
+
|
|
103
|
+
patched_agent_request = cls(
|
|
104
|
+
name=name,
|
|
105
|
+
endpoint=endpoint,
|
|
106
|
+
agent_type=agent_type,
|
|
107
|
+
description=description,
|
|
108
|
+
metadata=metadata,
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
patched_agent_request.additional_properties = d
|
|
112
|
+
return patched_agent_request
|
|
113
|
+
|
|
114
|
+
@property
|
|
115
|
+
def additional_keys(self) -> list[str]:
|
|
116
|
+
return list(self.additional_properties.keys())
|
|
117
|
+
|
|
118
|
+
def __getitem__(self, key: str) -> Any:
|
|
119
|
+
return self.additional_properties[key]
|
|
120
|
+
|
|
121
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
122
|
+
self.additional_properties[key] = value
|
|
123
|
+
|
|
124
|
+
def __delitem__(self, key: str) -> None:
|
|
125
|
+
del self.additional_properties[key]
|
|
126
|
+
|
|
127
|
+
def __contains__(self, key: str) -> bool:
|
|
128
|
+
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,71 @@
|
|
|
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="PatchedOrganizationRequest")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@_attrs_define
|
|
14
|
+
class PatchedOrganizationRequest:
|
|
15
|
+
"""
|
|
16
|
+
Attributes:
|
|
17
|
+
name (Union[Unset, str]):
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
name: Union[Unset, str] = UNSET
|
|
21
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
22
|
+
|
|
23
|
+
def to_dict(self) -> dict[str, Any]:
|
|
24
|
+
name = self.name
|
|
25
|
+
|
|
26
|
+
field_dict: dict[str, Any] = {}
|
|
27
|
+
field_dict.update(self.additional_properties)
|
|
28
|
+
field_dict.update({})
|
|
29
|
+
if name is not UNSET:
|
|
30
|
+
field_dict["name"] = name
|
|
31
|
+
|
|
32
|
+
return field_dict
|
|
33
|
+
|
|
34
|
+
def to_multipart(self) -> types.RequestFiles:
|
|
35
|
+
files: types.RequestFiles = []
|
|
36
|
+
|
|
37
|
+
if not isinstance(self.name, Unset):
|
|
38
|
+
files.append(("name", (None, str(self.name).encode(), "text/plain")))
|
|
39
|
+
|
|
40
|
+
for prop_name, prop in self.additional_properties.items():
|
|
41
|
+
files.append((prop_name, (None, str(prop).encode(), "text/plain")))
|
|
42
|
+
|
|
43
|
+
return files
|
|
44
|
+
|
|
45
|
+
@classmethod
|
|
46
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
47
|
+
d = dict(src_dict)
|
|
48
|
+
name = d.pop("name", UNSET)
|
|
49
|
+
|
|
50
|
+
patched_organization_request = cls(
|
|
51
|
+
name=name,
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
patched_organization_request.additional_properties = d
|
|
55
|
+
return patched_organization_request
|
|
56
|
+
|
|
57
|
+
@property
|
|
58
|
+
def additional_keys(self) -> list[str]:
|
|
59
|
+
return list(self.additional_properties.keys())
|
|
60
|
+
|
|
61
|
+
def __getitem__(self, key: str) -> Any:
|
|
62
|
+
return self.additional_properties[key]
|
|
63
|
+
|
|
64
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
65
|
+
self.additional_properties[key] = value
|
|
66
|
+
|
|
67
|
+
def __delitem__(self, key: str) -> None:
|
|
68
|
+
del self.additional_properties[key]
|
|
69
|
+
|
|
70
|
+
def __contains__(self, key: str) -> bool:
|
|
71
|
+
return key in self.additional_properties
|