hackagent 0.1.0__tar.gz → 0.2.0__tar.gz
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-0.1.0 → hackagent-0.2.0}/PKG-INFO +3 -4
- hackagent-0.2.0/assets/banner.png +0 -0
- hackagent-0.2.0/assets/favicon.ico +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/agent.py +30 -21
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/agent/agent_destroy.py +3 -1
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/agent/agent_partial_update.py +3 -1
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/agent/agent_retrieve.py +3 -1
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/agent/agent_update.py +3 -1
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/attack/attack_destroy.py +3 -1
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/attack/attack_partial_update.py +3 -1
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/attack/attack_retrieve.py +3 -1
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/attack/attack_update.py +3 -1
- hackagent-0.2.0/hackagent/api/generator/generator_create.py +99 -0
- hackagent-0.2.0/hackagent/api/judge/judge_create.py +99 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/key/key_destroy.py +3 -1
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/key/key_retrieve.py +3 -1
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/prompt/prompt_destroy.py +3 -1
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/prompt/prompt_partial_update.py +3 -1
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/prompt/prompt_retrieve.py +3 -1
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/prompt/prompt_update.py +3 -1
- hackagent-0.2.0/hackagent/api/result/__init__.py +1 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/result/result_destroy.py +3 -1
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/result/result_partial_update.py +3 -1
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/result/result_retrieve.py +3 -1
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/result/result_trace_create.py +7 -5
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/result/result_update.py +3 -1
- hackagent-0.2.0/hackagent/api/run/__init__.py +1 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/run/run_destroy.py +3 -1
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/run/run_partial_update.py +3 -1
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/run/run_result_create.py +3 -1
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/run/run_retrieve.py +3 -1
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/run/run_update.py +3 -1
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/AdvPrefix/completer.py +111 -163
- hackagent-0.2.0/hackagent/attacks/AdvPrefix/scorer_parser.py +606 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/AdvPrefix/step1_generate.py +10 -27
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/AdvPrefix/step4_compute_ce.py +43 -40
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/AdvPrefix/step6_get_completions.py +58 -108
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/AdvPrefix/step7_evaluate_responses.py +119 -71
- hackagent-0.2.0/hackagent/attacks/advprefix.py +848 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/strategies.py +135 -72
- hackagent-0.2.0/hackagent/branding.py +42 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/client.py +6 -1
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/errors.py +3 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/logger.py +1 -1
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/prompt.py +7 -9
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/user_api_key.py +16 -18
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/router/adapters/google_adk.py +1 -19
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/router/adapters/litellm_adapter.py +28 -57
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/router/base.py +1 -1
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/router/router.py +36 -42
- {hackagent-0.1.0 → hackagent-0.2.0}/pyproject.toml +10 -9
- hackagent-0.1.0/hackagent/attacks/AdvPrefix/scorer_parser.py +0 -498
- hackagent-0.1.0/hackagent/attacks/advprefix.py +0 -1136
- hackagent-0.1.0/hackagent/branding.py +0 -143
- {hackagent-0.1.0 → hackagent-0.2.0}/LICENSE +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/README.md +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/__init__.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/__init__.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/agent/__init__.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/agent/agent_create.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/agent/agent_list.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/attack/__init__.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/attack/attack_create.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/attack/attack_list.py +0 -0
- {hackagent-0.1.0/hackagent/api/key → hackagent-0.2.0/hackagent/api/generator}/__init__.py +0 -0
- {hackagent-0.1.0/hackagent/api/prompt → hackagent-0.2.0/hackagent/api/judge}/__init__.py +0 -0
- {hackagent-0.1.0/hackagent/api/result → hackagent-0.2.0/hackagent/api/key}/__init__.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/key/key_create.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/key/key_list.py +0 -0
- {hackagent-0.1.0/hackagent/api/run → hackagent-0.2.0/hackagent/api/prompt}/__init__.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/prompt/prompt_create.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/prompt/prompt_list.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/result/result_create.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/result/result_list.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/run/run_create.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/run/run_list.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/run/run_run_tests_create.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/AdvPrefix/README.md +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/AdvPrefix/__init__.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/AdvPrefix/config.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/AdvPrefix/preprocessing.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/AdvPrefix/scorer.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/AdvPrefix/selector.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/AdvPrefix/step8_aggregate_evaluations.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/AdvPrefix/step9_select_prefixes.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/AdvPrefix/utils.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/__init__.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/base.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/__init__.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/agent.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/agent_request.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/agent_type_enum.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/attack.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/attack_request.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/evaluation_status_enum.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/organization_minimal.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/paginated_agent_list.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/paginated_attack_list.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/paginated_prompt_list.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/paginated_result_list.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/paginated_run_list.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/paginated_user_api_key_list.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/patched_agent_request.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/patched_attack_request.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/patched_prompt_request.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/patched_result_request.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/patched_run_request.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/prompt_request.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/result.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/result_list_evaluation_status.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/result_request.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/run.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/run_list_status.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/run_request.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/status_enum.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/step_type_enum.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/trace.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/trace_request.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/user_api_key_request.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/user_profile_minimal.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/py.typed +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/router/__init__.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/router/adapters/__init__.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/types.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/utils.py +0 -0
- {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/vulnerabilities/__init__.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: hackagent
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: HackAgent is an open-source security toolkit to detect vulnerabilities of your AI Agents.
|
|
5
5
|
Author: Nicola Franco
|
|
6
6
|
Author-email: nicola@vista-labs.ai
|
|
7
7
|
Requires-Python: >=3.10,<4.0
|
|
@@ -10,8 +10,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
10
10
|
Classifier: Programming Language :: Python :: 3.11
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.12
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
-
Requires-Dist:
|
|
14
|
-
Requires-Dist: litellm (>=1.69.1,<2.0.0)
|
|
13
|
+
Requires-Dist: litellm (>=1.69.2,<2.0.0)
|
|
15
14
|
Requires-Dist: pandas (>=2.2.3,<3.0.0)
|
|
16
15
|
Requires-Dist: pydantic (>=2.0,<3.0)
|
|
17
16
|
Requires-Dist: python-dotenv (>=1.1.0,<2.0.0)
|
|
Binary file
|
|
Binary file
|
|
@@ -52,17 +52,21 @@ class HackAgent:
|
|
|
52
52
|
name: str = None,
|
|
53
53
|
agent_type: AgentTypeEnum = AgentTypeEnum.UNKNOWN,
|
|
54
54
|
base_url: Optional[str] = None,
|
|
55
|
-
|
|
55
|
+
api_key: Optional[str] = None,
|
|
56
56
|
predefined_prompts: Optional[Dict[str, Tuple[str, str]]] = None,
|
|
57
57
|
raise_on_unexpected_status: bool = False,
|
|
58
58
|
timeout: Optional[float] = None,
|
|
59
59
|
env_file_path: Optional[str] = None,
|
|
60
60
|
):
|
|
61
|
-
display_hackagent_splash()
|
|
61
|
+
display_hackagent_splash()
|
|
62
|
+
|
|
63
|
+
resolved_auth_token = self._resolve_api_token(
|
|
64
|
+
direct_api_key_param=api_key, env_file_path=env_file_path
|
|
65
|
+
)
|
|
62
66
|
|
|
63
67
|
self.client = AuthenticatedClient(
|
|
64
68
|
base_url=base_url,
|
|
65
|
-
token=
|
|
69
|
+
token=resolved_auth_token,
|
|
66
70
|
prefix="Api-Key",
|
|
67
71
|
raise_on_unexpected_status=raise_on_unexpected_status,
|
|
68
72
|
timeout=timeout,
|
|
@@ -85,33 +89,38 @@ class HackAgent:
|
|
|
85
89
|
}
|
|
86
90
|
|
|
87
91
|
def _resolve_api_token(
|
|
88
|
-
self,
|
|
92
|
+
self, direct_api_key_param: Optional[str], env_file_path: Optional[str]
|
|
89
93
|
) -> str:
|
|
90
|
-
"""Resolves the API token from direct
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
"""Resolves the API token from the direct api_key parameter or environment variables."""
|
|
95
|
+
if direct_api_key_param is not None:
|
|
96
|
+
logger.debug("Using API token provided directly via 'api_key' parameter.")
|
|
97
|
+
return direct_api_key_param
|
|
98
|
+
|
|
99
|
+
# If direct_api_key_param is None, attempt to load from environment.
|
|
100
|
+
logger.debug(
|
|
101
|
+
"API token not provided via 'api_key' parameter, attempting to load from environment."
|
|
102
|
+
)
|
|
103
|
+
dotenv_to_load = env_file_path or find_dotenv(usecwd=True)
|
|
97
104
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
105
|
+
if dotenv_to_load:
|
|
106
|
+
logger.debug(f"Loading .env file from: {dotenv_to_load}")
|
|
107
|
+
load_dotenv(dotenv_to_load)
|
|
108
|
+
else:
|
|
109
|
+
logger.debug("No .env file found to load.")
|
|
103
110
|
|
|
104
|
-
|
|
111
|
+
api_token_resolved = os.getenv("HACKAGENT_API_KEY")
|
|
105
112
|
|
|
106
113
|
if not api_token_resolved:
|
|
107
114
|
error_message = (
|
|
108
|
-
"API token not provided
|
|
109
|
-
"
|
|
115
|
+
"API token not provided via 'api_key' parameter, "
|
|
116
|
+
"and not found in HACKAGENT_API_KEY environment variable "
|
|
117
|
+
"(after attempting to load .env)."
|
|
110
118
|
)
|
|
111
119
|
raise ValueError(error_message)
|
|
120
|
+
logger.debug("Using API token from HACKAGENT_API_KEY environment variable.")
|
|
112
121
|
return api_token_resolved
|
|
113
122
|
|
|
114
|
-
|
|
123
|
+
def hack(
|
|
115
124
|
self,
|
|
116
125
|
attack_config: Dict[str, Any],
|
|
117
126
|
run_config_override: Optional[Dict[str, Any]] = None,
|
|
@@ -163,7 +172,7 @@ class HackAgent:
|
|
|
163
172
|
f"Using Victim Backend Agent ID: {backend_agent.id} for '{backend_agent.name}'"
|
|
164
173
|
)
|
|
165
174
|
|
|
166
|
-
return
|
|
175
|
+
return strategy.execute(
|
|
167
176
|
attack_config=attack_config,
|
|
168
177
|
run_config_override=run_config_override,
|
|
169
178
|
fail_on_run_error=fail_on_run_error,
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
from http import HTTPStatus
|
|
2
|
+
from typing import Any, Optional, Union
|
|
3
|
+
|
|
4
|
+
import httpx
|
|
5
|
+
|
|
6
|
+
from ... import errors
|
|
7
|
+
from ...client import AuthenticatedClient, Client
|
|
8
|
+
from ...types import Response
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def _get_kwargs() -> dict[str, Any]:
|
|
12
|
+
_kwargs: dict[str, Any] = {
|
|
13
|
+
"method": "post",
|
|
14
|
+
"url": "/api/generator",
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return _kwargs
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _parse_response(
|
|
21
|
+
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
|
22
|
+
) -> Optional[Any]:
|
|
23
|
+
if response.status_code == 200:
|
|
24
|
+
return None
|
|
25
|
+
if client.raise_on_unexpected_status:
|
|
26
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
|
27
|
+
else:
|
|
28
|
+
return None
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _build_response(
|
|
32
|
+
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
|
33
|
+
) -> Response[Any]:
|
|
34
|
+
return Response(
|
|
35
|
+
status_code=HTTPStatus(response.status_code),
|
|
36
|
+
content=response.content,
|
|
37
|
+
headers=response.headers,
|
|
38
|
+
parsed=_parse_response(client=client, response=response),
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def sync_detailed(
|
|
43
|
+
*,
|
|
44
|
+
client: AuthenticatedClient,
|
|
45
|
+
) -> Response[Any]:
|
|
46
|
+
r"""Proxies POST requests to the configured OpenRouter generator model.
|
|
47
|
+
Requires a valid User API Key for access.
|
|
48
|
+
The client should send a POST request with a JSON body in the same format
|
|
49
|
+
as expected by LiteLLM or OpenRouter's /chat/completions endpoint,
|
|
50
|
+
including a \"model\" field.
|
|
51
|
+
Note: The \"model\" field provided by the client in the request body will be
|
|
52
|
+
overridden by the server-configured generator model ID for the actual call to OpenRouter.
|
|
53
|
+
e.g., {\"model\": \"client_specified_model_name\", \"messages\": [{\"role\": \"user\", \"content\":
|
|
54
|
+
\"Hello!\"}], \"stream\": False}
|
|
55
|
+
|
|
56
|
+
Raises:
|
|
57
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
58
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
59
|
+
|
|
60
|
+
Returns:
|
|
61
|
+
Response[Any]
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
kwargs = _get_kwargs()
|
|
65
|
+
|
|
66
|
+
response = client.get_httpx_client().request(
|
|
67
|
+
**kwargs,
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
return _build_response(client=client, response=response)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
async def asyncio_detailed(
|
|
74
|
+
*,
|
|
75
|
+
client: AuthenticatedClient,
|
|
76
|
+
) -> Response[Any]:
|
|
77
|
+
r"""Proxies POST requests to the configured OpenRouter generator model.
|
|
78
|
+
Requires a valid User API Key for access.
|
|
79
|
+
The client should send a POST request with a JSON body in the same format
|
|
80
|
+
as expected by LiteLLM or OpenRouter's /chat/completions endpoint,
|
|
81
|
+
including a \"model\" field.
|
|
82
|
+
Note: The \"model\" field provided by the client in the request body will be
|
|
83
|
+
overridden by the server-configured generator model ID for the actual call to OpenRouter.
|
|
84
|
+
e.g., {\"model\": \"client_specified_model_name\", \"messages\": [{\"role\": \"user\", \"content\":
|
|
85
|
+
\"Hello!\"}], \"stream\": False}
|
|
86
|
+
|
|
87
|
+
Raises:
|
|
88
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
89
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
90
|
+
|
|
91
|
+
Returns:
|
|
92
|
+
Response[Any]
|
|
93
|
+
"""
|
|
94
|
+
|
|
95
|
+
kwargs = _get_kwargs()
|
|
96
|
+
|
|
97
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
|
98
|
+
|
|
99
|
+
return _build_response(client=client, response=response)
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
from http import HTTPStatus
|
|
2
|
+
from typing import Any, Optional, Union
|
|
3
|
+
|
|
4
|
+
import httpx
|
|
5
|
+
|
|
6
|
+
from ... import errors
|
|
7
|
+
from ...client import AuthenticatedClient, Client
|
|
8
|
+
from ...types import Response
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def _get_kwargs() -> dict[str, Any]:
|
|
12
|
+
_kwargs: dict[str, Any] = {
|
|
13
|
+
"method": "post",
|
|
14
|
+
"url": "/api/judge",
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return _kwargs
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _parse_response(
|
|
21
|
+
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
|
22
|
+
) -> Optional[Any]:
|
|
23
|
+
if response.status_code == 200:
|
|
24
|
+
return None
|
|
25
|
+
if client.raise_on_unexpected_status:
|
|
26
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
|
27
|
+
else:
|
|
28
|
+
return None
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _build_response(
|
|
32
|
+
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
|
33
|
+
) -> Response[Any]:
|
|
34
|
+
return Response(
|
|
35
|
+
status_code=HTTPStatus(response.status_code),
|
|
36
|
+
content=response.content,
|
|
37
|
+
headers=response.headers,
|
|
38
|
+
parsed=_parse_response(client=client, response=response),
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def sync_detailed(
|
|
43
|
+
*,
|
|
44
|
+
client: AuthenticatedClient,
|
|
45
|
+
) -> Response[Any]:
|
|
46
|
+
r"""Proxies POST requests to the configured OpenRouter judge model.
|
|
47
|
+
Requires a valid User API Key for access.
|
|
48
|
+
The client should send a POST request with a JSON body in the same format
|
|
49
|
+
as expected by LiteLLM or OpenRouter's /chat/completions endpoint,
|
|
50
|
+
including a \"model\" field.
|
|
51
|
+
Note: The \"model\" field provided by the client in the request body will be
|
|
52
|
+
overridden by the server-configured judge model ID for the actual call to OpenRouter.
|
|
53
|
+
e.g., {\"model\": \"client_specified_model_name\", \"messages\": [{\"role\": \"user\", \"content\":
|
|
54
|
+
\"Is this good?\"}], \"stream\": False}
|
|
55
|
+
|
|
56
|
+
Raises:
|
|
57
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
58
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
59
|
+
|
|
60
|
+
Returns:
|
|
61
|
+
Response[Any]
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
kwargs = _get_kwargs()
|
|
65
|
+
|
|
66
|
+
response = client.get_httpx_client().request(
|
|
67
|
+
**kwargs,
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
return _build_response(client=client, response=response)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
async def asyncio_detailed(
|
|
74
|
+
*,
|
|
75
|
+
client: AuthenticatedClient,
|
|
76
|
+
) -> Response[Any]:
|
|
77
|
+
r"""Proxies POST requests to the configured OpenRouter judge model.
|
|
78
|
+
Requires a valid User API Key for access.
|
|
79
|
+
The client should send a POST request with a JSON body in the same format
|
|
80
|
+
as expected by LiteLLM or OpenRouter's /chat/completions endpoint,
|
|
81
|
+
including a \"model\" field.
|
|
82
|
+
Note: The \"model\" field provided by the client in the request body will be
|
|
83
|
+
overridden by the server-configured judge model ID for the actual call to OpenRouter.
|
|
84
|
+
e.g., {\"model\": \"client_specified_model_name\", \"messages\": [{\"role\": \"user\", \"content\":
|
|
85
|
+
\"Is this good?\"}], \"stream\": False}
|
|
86
|
+
|
|
87
|
+
Raises:
|
|
88
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
89
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
90
|
+
|
|
91
|
+
Returns:
|
|
92
|
+
Response[Any]
|
|
93
|
+
"""
|
|
94
|
+
|
|
95
|
+
kwargs = _get_kwargs()
|
|
96
|
+
|
|
97
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
|
98
|
+
|
|
99
|
+
return _build_response(client=client, response=response)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Contains endpoint functions for accessing the API"""
|
|
@@ -20,7 +20,9 @@ def _get_kwargs(
|
|
|
20
20
|
|
|
21
21
|
_kwargs: dict[str, Any] = {
|
|
22
22
|
"method": "post",
|
|
23
|
-
"url":
|
|
23
|
+
"url": "/api/result/{id}/trace".format(
|
|
24
|
+
id=id,
|
|
25
|
+
),
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
_body = body.to_dict()
|
|
@@ -63,7 +65,7 @@ def sync_detailed(
|
|
|
63
65
|
body: TraceRequest,
|
|
64
66
|
) -> Response[Trace]:
|
|
65
67
|
"""Creates a new Trace associated with this Result.
|
|
66
|
-
The result instance is fetched using the '
|
|
68
|
+
The result instance is fetched using the 'id' (the lookup_field) from the URL.
|
|
67
69
|
|
|
68
70
|
Args:
|
|
69
71
|
id (UUID):
|
|
@@ -96,7 +98,7 @@ def sync(
|
|
|
96
98
|
body: TraceRequest,
|
|
97
99
|
) -> Optional[Trace]:
|
|
98
100
|
"""Creates a new Trace associated with this Result.
|
|
99
|
-
The result instance is fetched using the '
|
|
101
|
+
The result instance is fetched using the 'id' (the lookup_field) from the URL.
|
|
100
102
|
|
|
101
103
|
Args:
|
|
102
104
|
id (UUID):
|
|
@@ -124,7 +126,7 @@ async def asyncio_detailed(
|
|
|
124
126
|
body: TraceRequest,
|
|
125
127
|
) -> Response[Trace]:
|
|
126
128
|
"""Creates a new Trace associated with this Result.
|
|
127
|
-
The result instance is fetched using the '
|
|
129
|
+
The result instance is fetched using the 'id' (the lookup_field) from the URL.
|
|
128
130
|
|
|
129
131
|
Args:
|
|
130
132
|
id (UUID):
|
|
@@ -155,7 +157,7 @@ async def asyncio(
|
|
|
155
157
|
body: TraceRequest,
|
|
156
158
|
) -> Optional[Trace]:
|
|
157
159
|
"""Creates a new Trace associated with this Result.
|
|
158
|
-
The result instance is fetched using the '
|
|
160
|
+
The result instance is fetched using the 'id' (the lookup_field) from the URL.
|
|
159
161
|
|
|
160
162
|
Args:
|
|
161
163
|
id (UUID):
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Contains endpoint functions for accessing the API"""
|