Skip to content

Commit c015dda

Browse files
committed
feat: changes in guardrails
1 parent 8dfe381 commit c015dda

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

portkey_ai/api_resources/apis/guardrails.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Any, Dict, List, Optional
1+
from typing import Any, Dict, List, Optional, Union
2+
from portkey_ai._vendor.openai import NOT_GIVEN, NotGiven
23
from portkey_ai.api_resources.base_client import APIClient, AsyncAPIClient
34
from urllib.parse import urlencode
45
from portkey_ai.api_resources.apis.api_resource import APIResource, AsyncAPIResource
@@ -22,8 +23,8 @@ def create(
2223
name: str,
2324
checks: List[Dict[str, Any]],
2425
actions: Dict[str, Any],
25-
workspace_id: Optional[str] = None,
26-
organisation_id: Optional[str] = None,
26+
workspace_id: Union[str, NotGiven] = NOT_GIVEN,
27+
organisation_id: Union[str, NotGiven] = NOT_GIVEN,
2728
**kwargs: Any,
2829
) -> GuardrailCreateResponse:
2930
body = {
@@ -47,8 +48,8 @@ def create(
4748
def list(
4849
self,
4950
*,
50-
workspace_id: Optional[str] = None,
51-
organisation_id: Optional[str] = None,
51+
workspace_id: Union[str, NotGiven] = NOT_GIVEN,
52+
organisation_id: Union[str, NotGiven] = NOT_GIVEN,
5253
page_size: Optional[int] = 100,
5354
current_page: Optional[int] = 0,
5455
) -> GuardrailListResponse:
@@ -58,7 +59,7 @@ def list(
5859
"page_size": page_size,
5960
"current_page": current_page,
6061
}
61-
filtered_query = {k: v for k, v in query.items() if v is not None}
62+
filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN}
6263
query_string = urlencode(filtered_query)
6364
return self._get(
6465
f"{PortkeyApiPaths.GUARDRAILS_API}?{query_string}",
@@ -89,9 +90,9 @@ def update(
8990
self,
9091
*,
9192
guardrail_id: str,
92-
name: Optional[str] = None,
93-
checks: Optional[List[Dict[str, Any]]] = None,
94-
actions: Optional[Dict[str, Any]] = None,
93+
name: Union[str, NotGiven] = NOT_GIVEN,
94+
checks: Union[List[Dict[str, Any]], NotGiven] = NOT_GIVEN,
95+
actions: Union[Dict[str, Any], NotGiven] = NOT_GIVEN,
9596
**kwargs: Any,
9697
) -> GuardrailUpdateResponse:
9798
body = {
@@ -136,8 +137,8 @@ async def create(
136137
name: str,
137138
checks: List[Dict[str, Any]],
138139
actions: Dict[str, Any],
139-
workspace_id: Optional[str] = None,
140-
organisation_id: Optional[str] = None,
140+
workspace_id: Union[str, NotGiven] = NOT_GIVEN,
141+
organisation_id: Union[str, NotGiven] = NOT_GIVEN,
141142
**kwargs: Any,
142143
) -> GuardrailCreateResponse:
143144
body = {
@@ -161,8 +162,8 @@ async def create(
161162
async def list(
162163
self,
163164
*,
164-
workspace_id: Optional[str] = None,
165-
organisation_id: Optional[str] = None,
165+
workspace_id: Union[str, NotGiven] = NOT_GIVEN,
166+
organisation_id: Union[str, NotGiven] = NOT_GIVEN,
166167
page_size: Optional[int] = 100,
167168
current_page: Optional[int] = 0,
168169
) -> GuardrailListResponse:
@@ -172,7 +173,7 @@ async def list(
172173
"page_size": page_size,
173174
"current_page": current_page,
174175
}
175-
filtered_query = {k: v for k, v in query.items() if v is not None}
176+
filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN}
176177
query_string = urlencode(filtered_query)
177178
return await self._get(
178179
f"{PortkeyApiPaths.GUARDRAILS_API}?{query_string}",
@@ -203,9 +204,9 @@ async def update(
203204
self,
204205
*,
205206
guardrail_id: str,
206-
name: Optional[str] = None,
207-
checks: Optional[List[Dict[str, Any]]] = None,
208-
actions: Optional[Dict[str, Any]] = None,
207+
name: Union[str, NotGiven] = NOT_GIVEN,
208+
checks: Union[List[Dict[str, Any]], NotGiven] = NOT_GIVEN,
209+
actions: Union[Dict[str, Any], NotGiven] = NOT_GIVEN,
209210
**kwargs: Any,
210211
) -> GuardrailUpdateResponse:
211212
body = {

0 commit comments

Comments
 (0)