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.
Files changed (126) hide show
  1. {hackagent-0.1.0 → hackagent-0.2.0}/PKG-INFO +3 -4
  2. hackagent-0.2.0/assets/banner.png +0 -0
  3. hackagent-0.2.0/assets/favicon.ico +0 -0
  4. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/agent.py +30 -21
  5. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/agent/agent_destroy.py +3 -1
  6. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/agent/agent_partial_update.py +3 -1
  7. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/agent/agent_retrieve.py +3 -1
  8. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/agent/agent_update.py +3 -1
  9. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/attack/attack_destroy.py +3 -1
  10. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/attack/attack_partial_update.py +3 -1
  11. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/attack/attack_retrieve.py +3 -1
  12. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/attack/attack_update.py +3 -1
  13. hackagent-0.2.0/hackagent/api/generator/generator_create.py +99 -0
  14. hackagent-0.2.0/hackagent/api/judge/judge_create.py +99 -0
  15. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/key/key_destroy.py +3 -1
  16. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/key/key_retrieve.py +3 -1
  17. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/prompt/prompt_destroy.py +3 -1
  18. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/prompt/prompt_partial_update.py +3 -1
  19. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/prompt/prompt_retrieve.py +3 -1
  20. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/prompt/prompt_update.py +3 -1
  21. hackagent-0.2.0/hackagent/api/result/__init__.py +1 -0
  22. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/result/result_destroy.py +3 -1
  23. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/result/result_partial_update.py +3 -1
  24. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/result/result_retrieve.py +3 -1
  25. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/result/result_trace_create.py +7 -5
  26. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/result/result_update.py +3 -1
  27. hackagent-0.2.0/hackagent/api/run/__init__.py +1 -0
  28. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/run/run_destroy.py +3 -1
  29. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/run/run_partial_update.py +3 -1
  30. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/run/run_result_create.py +3 -1
  31. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/run/run_retrieve.py +3 -1
  32. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/run/run_update.py +3 -1
  33. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/AdvPrefix/completer.py +111 -163
  34. hackagent-0.2.0/hackagent/attacks/AdvPrefix/scorer_parser.py +606 -0
  35. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/AdvPrefix/step1_generate.py +10 -27
  36. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/AdvPrefix/step4_compute_ce.py +43 -40
  37. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/AdvPrefix/step6_get_completions.py +58 -108
  38. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/AdvPrefix/step7_evaluate_responses.py +119 -71
  39. hackagent-0.2.0/hackagent/attacks/advprefix.py +848 -0
  40. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/strategies.py +135 -72
  41. hackagent-0.2.0/hackagent/branding.py +42 -0
  42. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/client.py +6 -1
  43. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/errors.py +3 -0
  44. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/logger.py +1 -1
  45. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/prompt.py +7 -9
  46. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/user_api_key.py +16 -18
  47. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/router/adapters/google_adk.py +1 -19
  48. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/router/adapters/litellm_adapter.py +28 -57
  49. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/router/base.py +1 -1
  50. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/router/router.py +36 -42
  51. {hackagent-0.1.0 → hackagent-0.2.0}/pyproject.toml +10 -9
  52. hackagent-0.1.0/hackagent/attacks/AdvPrefix/scorer_parser.py +0 -498
  53. hackagent-0.1.0/hackagent/attacks/advprefix.py +0 -1136
  54. hackagent-0.1.0/hackagent/branding.py +0 -143
  55. {hackagent-0.1.0 → hackagent-0.2.0}/LICENSE +0 -0
  56. {hackagent-0.1.0 → hackagent-0.2.0}/README.md +0 -0
  57. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/__init__.py +0 -0
  58. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/__init__.py +0 -0
  59. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/agent/__init__.py +0 -0
  60. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/agent/agent_create.py +0 -0
  61. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/agent/agent_list.py +0 -0
  62. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/attack/__init__.py +0 -0
  63. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/attack/attack_create.py +0 -0
  64. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/attack/attack_list.py +0 -0
  65. {hackagent-0.1.0/hackagent/api/key → hackagent-0.2.0/hackagent/api/generator}/__init__.py +0 -0
  66. {hackagent-0.1.0/hackagent/api/prompt → hackagent-0.2.0/hackagent/api/judge}/__init__.py +0 -0
  67. {hackagent-0.1.0/hackagent/api/result → hackagent-0.2.0/hackagent/api/key}/__init__.py +0 -0
  68. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/key/key_create.py +0 -0
  69. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/key/key_list.py +0 -0
  70. {hackagent-0.1.0/hackagent/api/run → hackagent-0.2.0/hackagent/api/prompt}/__init__.py +0 -0
  71. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/prompt/prompt_create.py +0 -0
  72. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/prompt/prompt_list.py +0 -0
  73. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/result/result_create.py +0 -0
  74. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/result/result_list.py +0 -0
  75. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/run/run_create.py +0 -0
  76. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/run/run_list.py +0 -0
  77. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/api/run/run_run_tests_create.py +0 -0
  78. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/AdvPrefix/README.md +0 -0
  79. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/AdvPrefix/__init__.py +0 -0
  80. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/AdvPrefix/config.py +0 -0
  81. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/AdvPrefix/preprocessing.py +0 -0
  82. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/AdvPrefix/scorer.py +0 -0
  83. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/AdvPrefix/selector.py +0 -0
  84. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/AdvPrefix/step8_aggregate_evaluations.py +0 -0
  85. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/AdvPrefix/step9_select_prefixes.py +0 -0
  86. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/AdvPrefix/utils.py +0 -0
  87. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/__init__.py +0 -0
  88. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/attacks/base.py +0 -0
  89. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/__init__.py +0 -0
  90. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/agent.py +0 -0
  91. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/agent_request.py +0 -0
  92. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/agent_type_enum.py +0 -0
  93. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/attack.py +0 -0
  94. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/attack_request.py +0 -0
  95. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/evaluation_status_enum.py +0 -0
  96. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/organization_minimal.py +0 -0
  97. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/paginated_agent_list.py +0 -0
  98. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/paginated_attack_list.py +0 -0
  99. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/paginated_prompt_list.py +0 -0
  100. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/paginated_result_list.py +0 -0
  101. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/paginated_run_list.py +0 -0
  102. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/paginated_user_api_key_list.py +0 -0
  103. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/patched_agent_request.py +0 -0
  104. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/patched_attack_request.py +0 -0
  105. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/patched_prompt_request.py +0 -0
  106. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/patched_result_request.py +0 -0
  107. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/patched_run_request.py +0 -0
  108. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/prompt_request.py +0 -0
  109. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/result.py +0 -0
  110. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/result_list_evaluation_status.py +0 -0
  111. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/result_request.py +0 -0
  112. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/run.py +0 -0
  113. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/run_list_status.py +0 -0
  114. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/run_request.py +0 -0
  115. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/status_enum.py +0 -0
  116. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/step_type_enum.py +0 -0
  117. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/trace.py +0 -0
  118. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/trace_request.py +0 -0
  119. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/user_api_key_request.py +0 -0
  120. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/models/user_profile_minimal.py +0 -0
  121. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/py.typed +0 -0
  122. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/router/__init__.py +0 -0
  123. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/router/adapters/__init__.py +0 -0
  124. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/types.py +0 -0
  125. {hackagent-0.1.0 → hackagent-0.2.0}/hackagent/utils.py +0 -0
  126. {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.1.0
4
- Summary: Python client for interacting with the HackAgent API.
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: google-adk (>=0.5.0,<0.6.0)
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
- token: Optional[str] = None,
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() # Display the splash screen on init
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=self._resolve_api_token(token, env_file_path),
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, token: Optional[str], env_file_path: Optional[str]
92
+ self, direct_api_key_param: Optional[str], env_file_path: Optional[str]
89
93
  ) -> str:
90
- """Resolves the API token from direct input or environment variables."""
91
- api_token_resolved = token
92
- if api_token_resolved is None:
93
- logger.debug(
94
- "API token not provided directly, attempting to load from environment."
95
- )
96
- dotenv_to_load = env_file_path or find_dotenv(usecwd=True)
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
- if dotenv_to_load:
99
- logger.debug(f"Loading .env file from: {dotenv_to_load}")
100
- load_dotenv(dotenv_to_load)
101
- else:
102
- logger.debug("No .env file found to load.")
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
- api_token_resolved = os.getenv("HACKAGENT_API_TOKEN")
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 and not found in HACKAGENT_API_TOKEN "
109
- "environment variable (after attempting to load .env)."
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
- async def hack(
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 await strategy.execute(
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,
@@ -14,7 +14,9 @@ def _get_kwargs(
14
14
  ) -> dict[str, Any]:
15
15
  _kwargs: dict[str, Any] = {
16
16
  "method": "delete",
17
- "url": f"/api/agent/{id}",
17
+ "url": "/api/agent/{id}".format(
18
+ id=id,
19
+ ),
18
20
  }
19
21
 
20
22
  return _kwargs
@@ -20,7 +20,9 @@ def _get_kwargs(
20
20
 
21
21
  _kwargs: dict[str, Any] = {
22
22
  "method": "patch",
23
- "url": f"/api/agent/{id}",
23
+ "url": "/api/agent/{id}".format(
24
+ id=id,
25
+ ),
24
26
  }
25
27
 
26
28
  _body = body.to_dict()
@@ -15,7 +15,9 @@ def _get_kwargs(
15
15
  ) -> dict[str, Any]:
16
16
  _kwargs: dict[str, Any] = {
17
17
  "method": "get",
18
- "url": f"/api/agent/{id}",
18
+ "url": "/api/agent/{id}".format(
19
+ id=id,
20
+ ),
19
21
  }
20
22
 
21
23
  return _kwargs
@@ -20,7 +20,9 @@ def _get_kwargs(
20
20
 
21
21
  _kwargs: dict[str, Any] = {
22
22
  "method": "put",
23
- "url": f"/api/agent/{id}",
23
+ "url": "/api/agent/{id}".format(
24
+ id=id,
25
+ ),
24
26
  }
25
27
 
26
28
  _body = body.to_dict()
@@ -14,7 +14,9 @@ def _get_kwargs(
14
14
  ) -> dict[str, Any]:
15
15
  _kwargs: dict[str, Any] = {
16
16
  "method": "delete",
17
- "url": f"/api/attack/{id}",
17
+ "url": "/api/attack/{id}".format(
18
+ id=id,
19
+ ),
18
20
  }
19
21
 
20
22
  return _kwargs
@@ -20,7 +20,9 @@ def _get_kwargs(
20
20
 
21
21
  _kwargs: dict[str, Any] = {
22
22
  "method": "patch",
23
- "url": f"/api/attack/{id}",
23
+ "url": "/api/attack/{id}".format(
24
+ id=id,
25
+ ),
24
26
  }
25
27
 
26
28
  _body = body.to_dict()
@@ -15,7 +15,9 @@ def _get_kwargs(
15
15
  ) -> dict[str, Any]:
16
16
  _kwargs: dict[str, Any] = {
17
17
  "method": "get",
18
- "url": f"/api/attack/{id}",
18
+ "url": "/api/attack/{id}".format(
19
+ id=id,
20
+ ),
19
21
  }
20
22
 
21
23
  return _kwargs
@@ -20,7 +20,9 @@ def _get_kwargs(
20
20
 
21
21
  _kwargs: dict[str, Any] = {
22
22
  "method": "put",
23
- "url": f"/api/attack/{id}",
23
+ "url": "/api/attack/{id}".format(
24
+ id=id,
25
+ ),
24
26
  }
25
27
 
26
28
  _body = body.to_dict()
@@ -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)
@@ -13,7 +13,9 @@ def _get_kwargs(
13
13
  ) -> dict[str, Any]:
14
14
  _kwargs: dict[str, Any] = {
15
15
  "method": "delete",
16
- "url": f"/api/key/{prefix}",
16
+ "url": "/api/key/{prefix}".format(
17
+ prefix=prefix,
18
+ ),
17
19
  }
18
20
 
19
21
  return _kwargs
@@ -14,7 +14,9 @@ def _get_kwargs(
14
14
  ) -> dict[str, Any]:
15
15
  _kwargs: dict[str, Any] = {
16
16
  "method": "get",
17
- "url": f"/api/key/{prefix}",
17
+ "url": "/api/key/{prefix}".format(
18
+ prefix=prefix,
19
+ ),
18
20
  }
19
21
 
20
22
  return _kwargs
@@ -14,7 +14,9 @@ def _get_kwargs(
14
14
  ) -> dict[str, Any]:
15
15
  _kwargs: dict[str, Any] = {
16
16
  "method": "delete",
17
- "url": f"/api/prompt/{id}",
17
+ "url": "/api/prompt/{id}".format(
18
+ id=id,
19
+ ),
18
20
  }
19
21
 
20
22
  return _kwargs
@@ -20,7 +20,9 @@ def _get_kwargs(
20
20
 
21
21
  _kwargs: dict[str, Any] = {
22
22
  "method": "patch",
23
- "url": f"/api/prompt/{id}",
23
+ "url": "/api/prompt/{id}".format(
24
+ id=id,
25
+ ),
24
26
  }
25
27
 
26
28
  _body = body.to_dict()
@@ -15,7 +15,9 @@ def _get_kwargs(
15
15
  ) -> dict[str, Any]:
16
16
  _kwargs: dict[str, Any] = {
17
17
  "method": "get",
18
- "url": f"/api/prompt/{id}",
18
+ "url": "/api/prompt/{id}".format(
19
+ id=id,
20
+ ),
19
21
  }
20
22
 
21
23
  return _kwargs
@@ -20,7 +20,9 @@ def _get_kwargs(
20
20
 
21
21
  _kwargs: dict[str, Any] = {
22
22
  "method": "put",
23
- "url": f"/api/prompt/{id}",
23
+ "url": "/api/prompt/{id}".format(
24
+ id=id,
25
+ ),
24
26
  }
25
27
 
26
28
  _body = body.to_dict()
@@ -0,0 +1 @@
1
+ """Contains endpoint functions for accessing the API"""
@@ -14,7 +14,9 @@ def _get_kwargs(
14
14
  ) -> dict[str, Any]:
15
15
  _kwargs: dict[str, Any] = {
16
16
  "method": "delete",
17
- "url": f"/api/result/{id}",
17
+ "url": "/api/result/{id}".format(
18
+ id=id,
19
+ ),
18
20
  }
19
21
 
20
22
  return _kwargs
@@ -20,7 +20,9 @@ def _get_kwargs(
20
20
 
21
21
  _kwargs: dict[str, Any] = {
22
22
  "method": "patch",
23
- "url": f"/api/result/{id}",
23
+ "url": "/api/result/{id}".format(
24
+ id=id,
25
+ ),
24
26
  }
25
27
 
26
28
  _body = body.to_dict()
@@ -15,7 +15,9 @@ def _get_kwargs(
15
15
  ) -> dict[str, Any]:
16
16
  _kwargs: dict[str, Any] = {
17
17
  "method": "get",
18
- "url": f"/api/result/{id}",
18
+ "url": "/api/result/{id}".format(
19
+ id=id,
20
+ ),
19
21
  }
20
22
 
21
23
  return _kwargs
@@ -20,7 +20,9 @@ def _get_kwargs(
20
20
 
21
21
  _kwargs: dict[str, Any] = {
22
22
  "method": "post",
23
- "url": f"/api/result/{id}/trace",
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 'pk' from the URL.
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 'pk' from the URL.
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 'pk' from the URL.
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 'pk' from the URL.
160
+ The result instance is fetched using the 'id' (the lookup_field) from the URL.
159
161
 
160
162
  Args:
161
163
  id (UUID):
@@ -20,7 +20,9 @@ def _get_kwargs(
20
20
 
21
21
  _kwargs: dict[str, Any] = {
22
22
  "method": "put",
23
- "url": f"/api/result/{id}",
23
+ "url": "/api/result/{id}".format(
24
+ id=id,
25
+ ),
24
26
  }
25
27
 
26
28
  _body = body.to_dict()
@@ -0,0 +1 @@
1
+ """Contains endpoint functions for accessing the API"""
@@ -14,7 +14,9 @@ def _get_kwargs(
14
14
  ) -> dict[str, Any]:
15
15
  _kwargs: dict[str, Any] = {
16
16
  "method": "delete",
17
- "url": f"/api/run/{id}",
17
+ "url": "/api/run/{id}".format(
18
+ id=id,
19
+ ),
18
20
  }
19
21
 
20
22
  return _kwargs
@@ -20,7 +20,9 @@ def _get_kwargs(
20
20
 
21
21
  _kwargs: dict[str, Any] = {
22
22
  "method": "patch",
23
- "url": f"/api/run/{id}",
23
+ "url": "/api/run/{id}".format(
24
+ id=id,
25
+ ),
24
26
  }
25
27
 
26
28
  _body = body.to_dict()
@@ -20,7 +20,9 @@ def _get_kwargs(
20
20
 
21
21
  _kwargs: dict[str, Any] = {
22
22
  "method": "post",
23
- "url": f"/api/run/{id}/result",
23
+ "url": "/api/run/{id}/result".format(
24
+ id=id,
25
+ ),
24
26
  }
25
27
 
26
28
  _body = body.to_dict()
@@ -15,7 +15,9 @@ def _get_kwargs(
15
15
  ) -> dict[str, Any]:
16
16
  _kwargs: dict[str, Any] = {
17
17
  "method": "get",
18
- "url": f"/api/run/{id}",
18
+ "url": "/api/run/{id}".format(
19
+ id=id,
20
+ ),
19
21
  }
20
22
 
21
23
  return _kwargs
@@ -20,7 +20,9 @@ def _get_kwargs(
20
20
 
21
21
  _kwargs: dict[str, Any] = {
22
22
  "method": "put",
23
- "url": f"/api/run/{id}",
23
+ "url": "/api/run/{id}".format(
24
+ id=id,
25
+ ),
24
26
  }
25
27
 
26
28
  _body = body.to_dict()