From e38953271586359af663dc2d7e8173669e3f80f3 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Fri, 31 Oct 2025 16:48:17 +0530 Subject: [PATCH 01/14] feat: removing NOT_GIVEN keys --- portkey_ai/api_resources/utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/portkey_ai/api_resources/utils.py b/portkey_ai/api_resources/utils.py index 03d64b1..bd124b8 100644 --- a/portkey_ai/api_resources/utils.py +++ b/portkey_ai/api_resources/utils.py @@ -8,6 +8,7 @@ import httpx import portkey_ai from pydantic import BaseModel +from .._vendor.openai._types import NOT_GIVEN from portkey_ai.api_resources.types.chat_complete_type import ( ChatCompletionChunk, @@ -239,9 +240,9 @@ def remove_empty_values( if isinstance(data, dict): cleaned_dict = {} for key, value in data.items(): - if value is not None and value != "": + if value is not NOT_GIVEN and value != "": cleaned_value = remove_empty_values(value) - if cleaned_value is not None and cleaned_value != "": + if cleaned_value is not NOT_GIVEN and cleaned_value != "": cleaned_dict[key] = cleaned_value return cleaned_dict elif isinstance(data, list): @@ -249,7 +250,7 @@ def remove_empty_values( for item in data: # type: ignore cleaned_item = remove_empty_values(item) - if cleaned_item is not None and cleaned_item != "": + if cleaned_item is not NOT_GIVEN and cleaned_item != "": cleaned_list.append(cleaned_item) return cleaned_list # type: ignore else: From b96c279ed44632a6e94b3fd98f5693df9cdef1a7 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Fri, 31 Oct 2025 17:14:15 +0530 Subject: [PATCH 02/14] feat: changes in api_keys --- portkey_ai/api_resources/apis/api_keys.py | 89 ++++++++++++----------- 1 file changed, 45 insertions(+), 44 deletions(-) diff --git a/portkey_ai/api_resources/apis/api_keys.py b/portkey_ai/api_resources/apis/api_keys.py index 8aad4e6..5169001 100644 --- a/portkey_ai/api_resources/apis/api_keys.py +++ b/portkey_ai/api_resources/apis/api_keys.py @@ -1,4 +1,5 @@ from typing import Any, Dict, List, Optional, Union +from portkey_ai._vendor.openai import NOT_GIVEN, NotGiven from portkey_ai.api_resources.base_client import APIClient, AsyncAPIClient from urllib.parse import urlencode from portkey_ai.api_resources.apis.api_resource import APIResource, AsyncAPIResource @@ -18,17 +19,17 @@ def __init__(self, client: APIClient) -> None: def create( self, *, - type: Optional[str] = None, - sub_type: Optional[str] = None, - name: Optional[str] = None, - description: Optional[str] = None, - workspace_id: Optional[str] = None, - user_id: Optional[str] = None, - rate_limits: Optional[List[Dict[str, Any]]] = None, - usage_limits: Optional[Dict[str, Any]] = None, - scopes: List[str], - defaults: Optional[Dict[str, Any]] = None, - expires_at: Optional[Any] = None, + type: Union[str, NotGiven] = NOT_GIVEN, + sub_type: Union[str, NotGiven] = NOT_GIVEN, + name: Union[str, NotGiven] = NOT_GIVEN, + description: Union[str, NotGiven] = NOT_GIVEN, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + user_id: Union[str, NotGiven] = NOT_GIVEN, + rate_limits: Union[List[Dict[str, Any]], NotGiven] = NOT_GIVEN, + usage_limits: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + scopes: Union[List[str], NotGiven] = NOT_GIVEN, + defaults: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + expires_at: Union[Any, NotGiven] = NOT_GIVEN, **kwargs: Any, ) -> ApiKeyAddResponse: body = { @@ -69,16 +70,16 @@ def retrieve(self, *, id: Optional[str]) -> ApiKeyGetResponse: def list( self, *, - page_size: Optional[Union[int, str]] = None, + page_size: Union[int, str, NotGiven] = NOT_GIVEN, current_page: Optional[int] = 0, - workspace_id: Optional[str] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, ) -> ApiKeyListResponse: query = { "page_size": page_size, "current_page": current_page, "workspace_id": workspace_id, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return self._get( f"{PortkeyApiPaths.API_KEYS_API}?{query_string}", @@ -93,14 +94,14 @@ def list( def update( self, *, - id: Optional[str] = None, - name: Optional[str] = None, - description: Optional[str] = None, - rate_limits: Optional[List[Dict[str, Any]]] = None, - usage_limits: Optional[Dict[str, Any]] = None, - scopes: Optional[List[str]] = None, - defaults: Optional[Dict[str, Any]] = None, - expires_at: Optional[Any] = None, + id: Union[str, NotGiven] = NOT_GIVEN, + name: Union[str, NotGiven] = NOT_GIVEN, + description: Union[str, NotGiven] = NOT_GIVEN, + rate_limits: Union[List[Dict[str, Any]], NotGiven] = NOT_GIVEN, + usage_limits: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + scopes: Union[List[str], NotGiven] = NOT_GIVEN, + defaults: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + expires_at: Union[Any, NotGiven] = NOT_GIVEN, **kwargs: Any, ) -> Any: body = { @@ -147,17 +148,17 @@ def __init__(self, client: AsyncAPIClient) -> None: async def create( self, *, - type: Optional[str] = None, - sub_type: Optional[str] = None, - name: Optional[str] = None, - description: Optional[str] = None, - workspace_id: Optional[str] = None, - user_id: Optional[str] = None, - rate_limits: Optional[List[Dict[str, Any]]] = None, - usage_limits: Optional[Dict[str, Any]] = None, - scopes: List[str], - defaults: Optional[Dict[str, Any]] = None, - expires_at: Optional[Any] = None, + type: Union[str, NotGiven] = NOT_GIVEN, + sub_type: Union[str, NotGiven] = NOT_GIVEN, + name: Union[str, NotGiven] = NOT_GIVEN, + description: Union[str, NotGiven] = NOT_GIVEN, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + user_id: Union[str, NotGiven] = NOT_GIVEN, + rate_limits: Union[List[Dict[str, Any]], NotGiven] = NOT_GIVEN, + usage_limits: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + scopes: Union[List[str], NotGiven] = NOT_GIVEN, + defaults: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + expires_at: Union[Any, NotGiven] = NOT_GIVEN, **kwargs: Any, ) -> ApiKeyAddResponse: body = { @@ -198,16 +199,16 @@ async def retrieve(self, *, id: Optional[str]) -> ApiKeyGetResponse: async def list( self, *, - page_size: Optional[Union[int, str]] = None, + page_size: Union[int, str, NotGiven] = NOT_GIVEN, current_page: Optional[int] = 0, - workspace_id: Optional[str] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, ) -> ApiKeyListResponse: query = { "page_size": page_size, "current_page": current_page, "workspace_id": workspace_id, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return await self._get( f"{PortkeyApiPaths.API_KEYS_API}?{query_string}", @@ -222,14 +223,14 @@ async def list( async def update( self, *, - id: Optional[str] = None, - name: Optional[str] = None, - description: Optional[str] = None, - rate_limits: Optional[List[Dict[str, Any]]] = None, - usage_limits: Optional[Dict[str, Any]] = None, - scopes: Optional[List[str]] = None, - defaults: Optional[Dict[str, Any]] = None, - expires_at: Optional[Any] = None, + id: Union[str, NotGiven] = NOT_GIVEN, + name: Union[str, NotGiven] = NOT_GIVEN, + description: Union[str, NotGiven] = NOT_GIVEN, + rate_limits: Union[List[Dict[str, Any]], NotGiven] = NOT_GIVEN, + usage_limits: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + scopes: Union[List[str], NotGiven] = NOT_GIVEN, + defaults: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + expires_at: Union[Any, NotGiven] = NOT_GIVEN, **kwargs: Any, ) -> Any: body = { From a0f9823b4297a38c87de45be9e1264154e46522c Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Fri, 31 Oct 2025 18:44:45 +0530 Subject: [PATCH 03/14] feat: changes in users and workspaces --- portkey_ai/api_resources/apis/admin.py | 157 +++++++++++++------------ 1 file changed, 79 insertions(+), 78 deletions(-) diff --git a/portkey_ai/api_resources/apis/admin.py b/portkey_ai/api_resources/apis/admin.py index 42bc99a..343d780 100644 --- a/portkey_ai/api_resources/apis/admin.py +++ b/portkey_ai/api_resources/apis/admin.py @@ -1,4 +1,5 @@ from typing import Any, Dict, List, Literal, Optional, Union +from portkey_ai._vendor.openai import NOT_GIVEN, NotGiven from portkey_ai.api_resources.base_client import APIClient, AsyncAPIClient from urllib.parse import urlencode from portkey_ai.api_resources.apis.api_resource import APIResource, AsyncAPIResource @@ -45,10 +46,10 @@ def retrieve(self, *, user_id: str) -> UserRetrieveResponse: def list( self, *, - page_size: Optional[Union[int, str]] = None, + page_size: Union[int, str, NotGiven] = NOT_GIVEN, current_page: Optional[int] = 0, - email: Optional[str] = None, - role: Optional[str] = None, + email: Union[str, NotGiven] = NOT_GIVEN, + role: Union[str, NotGiven] = NOT_GIVEN, ) -> UserRetrieveAllResponse: query = { "pageSize": page_size, @@ -56,7 +57,7 @@ def list( "email": email, "role": role, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return self._get( f"{PortkeyApiPaths.USER_API}?{query_string}", @@ -99,10 +100,10 @@ def __init__(self, client: APIClient) -> None: def create( self, *, - email: Optional[str] = None, - role: Optional[str] = None, - workspaces: Optional[List[Dict[str, Any]]] = None, - workspace_api_key_details: Optional[Dict[str, Any]] = None, + email: Union[str, NotGiven] = NOT_GIVEN, + role: Union[str, NotGiven] = NOT_GIVEN, + workspaces: Union[List[Dict[str, Any]], NotGiven] = NOT_GIVEN, + workspace_api_key_details: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, ) -> UserInviteResponse: body = { "email": email, @@ -134,11 +135,11 @@ def retrieve(self, *, invite_id: str) -> UserInviteRetrieveResponse: def list( self, *, - page_size: Optional[Union[int, str]] = None, + page_size: Union[int, str, NotGiven] = NOT_GIVEN, current_page: Optional[int] = 0, - email: Optional[str] = None, - role: Optional[str] = None, - status: Optional[str] = None, + email: Union[str, NotGiven] = NOT_GIVEN, + role: Union[str, NotGiven] = NOT_GIVEN, + status: Union[str, NotGiven] = NOT_GIVEN, ) -> UserInviteRetrieveAllResponse: query = { "pageSize": page_size, @@ -147,7 +148,7 @@ def list( "role": role, "status": status, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return self._get( f"{PortkeyApiPaths.INVITE_API}?{query_string}", @@ -190,10 +191,10 @@ def __init__(self, client: APIClient) -> None: def create( self, *, - name: Optional[str] = None, - description: Optional[str] = None, - defaults: Optional[Dict[str, Any]] = None, - users: Optional[List[str]] = None, + name: Union[str, NotGiven] = NOT_GIVEN, + description: Union[str, NotGiven] = NOT_GIVEN, + defaults: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + users: Union[List[str], NotGiven] = NOT_GIVEN, ) -> WorkspacesAddResponse: body = { "name": name, @@ -225,10 +226,10 @@ def retrieve(self, *, workspace_id: str) -> WorkspacesGetResponse: def list( self, *, - name: Optional[str] = None, - page_size: Optional[Union[int, str]] = None, + name: Union[str, NotGiven] = NOT_GIVEN, + page_size: Union[int, str, NotGiven] = NOT_GIVEN, current_page: Optional[int] = 0, - exact_name: Optional[str] = None, + exact_name: Union[str, NotGiven] = NOT_GIVEN, **kwargs: Any, ) -> WorkspacesListResponse: query = { @@ -238,7 +239,7 @@ def list( "exact_name": exact_name, **kwargs, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return self._get( f"{PortkeyApiPaths.WORKSPACE_API}?{query_string}", @@ -253,10 +254,10 @@ def list( def update( self, *, - workspace_id: Optional[str] = None, - name: Optional[str] = None, - description: Optional[str] = None, - defaults: Optional[Dict[str, Any]] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + name: Union[str, NotGiven] = NOT_GIVEN, + description: Union[str, NotGiven] = NOT_GIVEN, + defaults: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, ) -> WorkspacesUpdateResponse: body = { "name": name, @@ -277,7 +278,7 @@ def delete( self, *, workspace_id: Optional[str], - name: Optional[str] = None, + name: Union[str, NotGiven] = NOT_GIVEN, ) -> Any: body = { "workspace_id": workspace_id, @@ -301,8 +302,8 @@ def __init__(self, client: APIClient) -> None: def create( self, *, - workspace_id: Optional[str] = None, - users: Optional[List[Dict[str, str]]] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + users: Union[List[Dict[str, str]], NotGiven] = NOT_GIVEN, ) -> Any: body = { "workspace_id": workspace_id, @@ -321,8 +322,8 @@ def create( def retrieve( self, *, - workspace_id: Optional[str] = None, - user_id: Optional[str] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + user_id: Union[str, NotGiven] = NOT_GIVEN, ) -> WorkspaceMemberGetResponse: return self._get( f"{PortkeyApiPaths.WORKSPACE_API}/{workspace_id}/users/{user_id}", @@ -337,11 +338,11 @@ def retrieve( def list( self, *, - workspace_id: Optional[str] = None, - page_size: Optional[Union[int, str]] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + page_size: Union[int, str, NotGiven] = NOT_GIVEN, current_page: Optional[int] = 0, - email: Optional[str] = None, - role: Optional[Union[Literal["admin", "manager", "member"], str]] = None, + email: Union[str, NotGiven] = NOT_GIVEN, + role: Union[Literal["admin", "manager", "member"], str, NotGiven] = NOT_GIVEN, ) -> Any: query = { "page_size": page_size, @@ -349,7 +350,7 @@ def list( "email": email, "role": role, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return self._get( f"{PortkeyApiPaths.WORKSPACE_API}/{workspace_id}/users?{query_string}", @@ -364,9 +365,9 @@ def list( def update( self, *, - workspace_id: Optional[str] = None, - user_id: Optional[str] = None, - role: Optional[Union[Literal["admin", "manager", "member"], str]] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + user_id: Union[str, NotGiven] = NOT_GIVEN, + role: Union[Literal["admin", "manager", "member"], str, NotGiven] = NOT_GIVEN, ) -> Any: body = { "user_id": user_id, @@ -386,7 +387,7 @@ def delete( self, *, workspace_id: Optional[str], - user_id: Optional[str] = None, + user_id: Union[str, NotGiven] = NOT_GIVEN, ) -> Any: return self._delete( f"{PortkeyApiPaths.WORKSPACE_API}/{workspace_id}/users/{user_id}", @@ -425,10 +426,10 @@ async def retrieve(self, *, user_id: str) -> UserRetrieveResponse: async def list( self, *, - page_size: Optional[Union[int, str]] = None, + page_size: Union[int, str, NotGiven] = NOT_GIVEN, current_page: Optional[int] = 0, - email: Optional[str] = None, - role: Optional[str] = None, + email: Union[str, NotGiven] = NOT_GIVEN, + role: Union[str, NotGiven] = NOT_GIVEN, ) -> UserRetrieveAllResponse: query = { "pageSize": page_size, @@ -436,7 +437,7 @@ async def list( "email": email, "role": role, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return await self._get( f"{PortkeyApiPaths.USER_API}?{query_string}", @@ -490,10 +491,10 @@ def __init__(self, client: AsyncAPIClient) -> None: async def create( self, *, - email: Optional[str] = None, - role: Optional[str] = None, - workspaces: Optional[List[Dict[str, Any]]] = None, - workspace_api_key_details: Optional[Dict[str, Any]] = None, + email: Union[str, NotGiven] = NOT_GIVEN, + role: Union[str, NotGiven] = NOT_GIVEN, + workspaces: Union[List[Dict[str, Any]], NotGiven] = NOT_GIVEN, + workspace_api_key_details: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, ) -> UserInviteResponse: body = { "email": email, @@ -525,11 +526,11 @@ async def retrieve(self, *, invite_id: str) -> UserInviteRetrieveResponse: async def list( self, *, - page_size: Optional[Union[int, str]] = None, + page_size: Union[int, str, NotGiven] = NOT_GIVEN, current_page: Optional[int] = 0, - email: Optional[str] = None, - role: Optional[str] = None, - status: Optional[str] = None, + email: Union[str, NotGiven] = NOT_GIVEN, + role: Union[str, NotGiven] = NOT_GIVEN, + status: Union[str, NotGiven] = NOT_GIVEN, ) -> UserInviteRetrieveAllResponse: query = { "pageSize": page_size, @@ -538,7 +539,7 @@ async def list( "role": role, "status": status, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return await self._get( f"{PortkeyApiPaths.INVITE_API}?{query_string}", @@ -570,10 +571,10 @@ def __init__(self, client: AsyncAPIClient) -> None: async def create( self, *, - name: Optional[str] = None, - description: Optional[str] = None, - defaults: Optional[Dict[str, Any]] = None, - users: Optional[List[str]] = None, + name: Union[str, NotGiven] = NOT_GIVEN, + description: Union[str, NotGiven] = NOT_GIVEN, + defaults: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + users: Union[List[str], NotGiven] = NOT_GIVEN, ) -> WorkspacesAddResponse: body = { "name": name, @@ -605,10 +606,10 @@ async def retrieve(self, *, workspace_id: str) -> WorkspacesGetResponse: async def list( self, *, - name: Optional[str] = None, - page_size: Optional[Union[int, str]] = None, + name: Union[str, NotGiven] = NOT_GIVEN, + page_size: Union[int, str, NotGiven] = NOT_GIVEN, current_page: Optional[int] = 0, - exact_name: Optional[str] = None, + exact_name: Union[str, NotGiven] = NOT_GIVEN, **kwargs: Any, ) -> WorkspacesListResponse: query = { @@ -618,7 +619,7 @@ async def list( "exact_name": exact_name, **kwargs, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return await self._get( f"{PortkeyApiPaths.WORKSPACE_API}?{query_string}", @@ -633,10 +634,10 @@ async def list( async def update( self, *, - workspace_id: Optional[str] = None, - name: Optional[str] = None, - description: Optional[str] = None, - defaults: Optional[Dict[str, Any]] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + name: Union[str, NotGiven] = NOT_GIVEN, + description: Union[str, NotGiven] = NOT_GIVEN, + defaults: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, ) -> WorkspacesUpdateResponse: body = { "name": name, @@ -657,7 +658,7 @@ async def delete( self, *, workspace_id: Optional[str], - name: Optional[str] = None, + name: Union[str, NotGiven] = NOT_GIVEN, ) -> Any: body = { "workspace_id": workspace_id, @@ -681,8 +682,8 @@ def __init__(self, client: AsyncAPIClient) -> None: async def create( self, *, - workspace_id: Optional[str] = None, - users: Optional[List[Dict[str, str]]] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + users: Union[List[Dict[str, str]], NotGiven] = NOT_GIVEN, ) -> Any: body = { "workspace_id": workspace_id, @@ -701,8 +702,8 @@ async def create( async def retrieve( self, *, - workspace_id: Optional[str] = None, - user_id: Optional[str] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + user_id: Union[str, NotGiven] = NOT_GIVEN, ) -> WorkspaceMemberGetResponse: return await self._get( f"{PortkeyApiPaths.WORKSPACE_API}/{workspace_id}/users/{user_id}", @@ -717,11 +718,11 @@ async def retrieve( async def list( self, *, - workspace_id: Optional[str] = None, - page_size: Optional[Union[int, str]] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + page_size: Union[int, str, NotGiven] = NOT_GIVEN, current_page: Optional[int] = 0, - email: Optional[str] = None, - role: Optional[Union[Literal["admin", "manager", "member"], str]] = None, + email: Union[str, NotGiven] = NOT_GIVEN, + role: Union[Literal["admin", "manager", "member"], str, NotGiven] = NOT_GIVEN, ) -> WorkspaceMemberListResponse: query = { "page_size": page_size, @@ -729,7 +730,7 @@ async def list( "email": email, "role": role, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return await self._get( f"{PortkeyApiPaths.WORKSPACE_API}/{workspace_id}/users?{query_string}", @@ -744,9 +745,9 @@ async def list( async def update( self, *, - workspace_id: Optional[str] = None, - user_id: Optional[str] = None, - role: Optional[Union[Literal["admin", "manager", "member"], str]] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + user_id: Union[str, NotGiven] = NOT_GIVEN, + role: Union[Literal["admin", "manager", "member"], str, NotGiven] = NOT_GIVEN, ) -> Any: body = { "user_id": user_id, @@ -766,7 +767,7 @@ async def delete( self, *, workspace_id: Optional[str], - user_id: Optional[str] = None, + user_id: Union[str, NotGiven] = NOT_GIVEN, ) -> Any: return await self._delete( f"{PortkeyApiPaths.WORKSPACE_API}/{workspace_id}/users/{user_id}", From 634aa258e92970848ee4971bcd9595012e99dfa0 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Fri, 31 Oct 2025 18:48:18 +0530 Subject: [PATCH 04/14] feat: changes in virtual keys --- portkey_ai/api_resources/apis/virtual_keys.py | 71 ++++++++++--------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/portkey_ai/api_resources/apis/virtual_keys.py b/portkey_ai/api_resources/apis/virtual_keys.py index 722ae32..9f74822 100644 --- a/portkey_ai/api_resources/apis/virtual_keys.py +++ b/portkey_ai/api_resources/apis/virtual_keys.py @@ -1,4 +1,5 @@ -from typing import Any, Dict, List, Optional +from typing import Any, Dict, List, Optional, Union +from portkey_ai._vendor.openai import NOT_GIVEN, NotGiven from portkey_ai.api_resources.base_client import APIClient, AsyncAPIClient from urllib.parse import urlencode from portkey_ai.api_resources.apis.api_resource import APIResource, AsyncAPIResource @@ -18,15 +19,15 @@ def __init__(self, client: APIClient) -> None: def create( self, *, - name: Optional[str] = None, - provider: Optional[str] = None, - key: Optional[str] = None, - note: Optional[str] = None, - apiVersion: Optional[str] = None, - resourceName: Optional[str] = None, - deploymentName: Optional[str] = None, - workspace_id: Optional[str] = None, - usage_limits: Optional[Dict[str, Any]] = None, + name: Union[str, NotGiven] = NOT_GIVEN, + provider: Union[str, NotGiven] = NOT_GIVEN, + key: Union[str, NotGiven] = NOT_GIVEN, + note: Union[str, NotGiven] = NOT_GIVEN, + apiVersion: Union[str, NotGiven] = NOT_GIVEN, + resourceName: Union[str, NotGiven] = NOT_GIVEN, + deploymentName: Union[str, NotGiven] = NOT_GIVEN, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + usage_limits: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, **kwargs: Any, ) -> VirtualKeysAddResponse: body = { @@ -54,10 +55,10 @@ def create( def list( self, *, - workspace_id: Optional[str] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, ) -> VirtualKeysListReponse: query = {"workspace_id": workspace_id} - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return self._get( f"{PortkeyApiPaths.VIRTUAL_KEYS_API}?{query_string}", @@ -83,12 +84,12 @@ def retrieve(self, *, slug: Optional[str]) -> Any: def update( self, *, - slug: Optional[str] = None, - name: Optional[str] = None, - key: Optional[str] = None, - note: Optional[str] = None, - usage_limits: Optional[Dict[str, Any]] = None, - rate_limits: Optional[List[Dict[str, Any]]] = None, + slug: Union[str, NotGiven] = NOT_GIVEN, + name: Union[str, NotGiven] = NOT_GIVEN, + key: Union[str, NotGiven] = NOT_GIVEN, + note: Union[str, NotGiven] = NOT_GIVEN, + usage_limits: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + rate_limits: Union[List[Dict[str, Any]], NotGiven] = NOT_GIVEN, **kwargs: Any, ) -> VirtualKeysUpdateResponse: body = { @@ -132,15 +133,15 @@ def __init__(self, client: AsyncAPIClient) -> None: async def create( self, *, - name: Optional[str] = None, - provider: Optional[str] = None, - key: Optional[str] = None, - note: Optional[str] = None, - apiVersion: Optional[str] = None, - resourceName: Optional[str] = None, - deploymentName: Optional[str] = None, - workspace_id: Optional[str] = None, - usage_limits: Optional[Dict[str, Any]] = None, + name: Union[str, NotGiven] = NOT_GIVEN, + provider: Union[str, NotGiven] = NOT_GIVEN, + key: Union[str, NotGiven] = NOT_GIVEN, + note: Union[str, NotGiven] = NOT_GIVEN, + apiVersion: Union[str, NotGiven] = NOT_GIVEN, + resourceName: Union[str, NotGiven] = NOT_GIVEN, + deploymentName: Union[str, NotGiven] = NOT_GIVEN, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + usage_limits: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, **kwargs: Any, ) -> VirtualKeysAddResponse: body = { @@ -168,10 +169,10 @@ async def create( async def list( self, *, - workspace_id: Optional[str] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, ) -> VirtualKeysListReponse: query = {"workspace_id": workspace_id} - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return await self._get( f"{PortkeyApiPaths.VIRTUAL_KEYS_API}?{query_string}", @@ -197,12 +198,12 @@ async def retrieve(self, *, slug: Optional[str]) -> Any: async def update( self, *, - slug: Optional[str] = None, - name: Optional[str] = None, - key: Optional[str] = None, - note: Optional[str] = None, - usage_limits: Optional[Dict[str, Any]] = None, - rate_limits: Optional[List[Dict[str, Any]]] = None, + slug: Union[str, NotGiven] = NOT_GIVEN, + name: Union[str, NotGiven] = NOT_GIVEN, + key: Union[str, NotGiven] = NOT_GIVEN, + note: Union[str, NotGiven] = NOT_GIVEN, + usage_limits: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + rate_limits: Union[List[Dict[str, Any]], NotGiven] = NOT_GIVEN, **kwargs: Any, ) -> VirtualKeysUpdateResponse: body = { From 0e99ad1a0b0a7f3f73cd2bd3c8c1a49524b4b54e Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Fri, 31 Oct 2025 18:50:20 +0530 Subject: [PATCH 05/14] feat: changes in logs and logs export --- portkey_ai/api_resources/apis/logs.py | 55 ++++++++++++++------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/portkey_ai/api_resources/apis/logs.py b/portkey_ai/api_resources/apis/logs.py index 0195494..176bd31 100644 --- a/portkey_ai/api_resources/apis/logs.py +++ b/portkey_ai/api_resources/apis/logs.py @@ -1,4 +1,5 @@ -from typing import Any, Dict, List, Optional +from typing import Any, Dict, List, Optional, Union +from portkey_ai._vendor.openai import NOT_GIVEN, NotGiven from portkey_ai.api_resources.base_client import APIClient, AsyncAPIClient from urllib.parse import urlencode from portkey_ai.api_resources.apis.api_resource import APIResource, AsyncAPIResource @@ -22,9 +23,9 @@ def __init__(self, client: APIClient) -> None: def create( self, *, - request: Optional[Dict[str, Any]] = None, - response: Optional[Dict[str, Any]] = None, - metadata: Optional[Dict[str, Any]] = None, + request: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + response: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + metadata: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, ) -> Any: body = { "request": request, @@ -50,10 +51,10 @@ def __init__(self, client: APIClient) -> None: def create( self, *, - filters: Optional[Dict[str, Any]] = None, - workspace_id: Optional[str] = None, - description: Optional[str] = None, - requested_data: Optional[List[str]] = None, + filters: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + description: Union[str, NotGiven] = NOT_GIVEN, + requested_data: Union[List[str], NotGiven] = NOT_GIVEN, ) -> LogsExportCreateResponse: body = { "filters": filters, @@ -85,12 +86,12 @@ def retrieve(self, *, export_id: str) -> LogsExportRetrieveResponse: def list( self, *, - workspace_id: Optional[str] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, ) -> LogsExportListResponse: query = { "workspace_id": workspace_id, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return self._get( f"{PortkeyApiPaths.LOGS_EXPORT_API}?{query_string}", @@ -105,10 +106,10 @@ def list( def update( self, *, - export_id: Optional[str] = None, - workspace_id: Optional[str] = None, - filters: Optional[Dict[str, Any]] = None, - requested_data: Optional[List[str]] = None, + export_id: Union[str, NotGiven] = NOT_GIVEN, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + filters: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + requested_data: Union[List[str], NotGiven] = NOT_GIVEN, ) -> LogsExportUpdateResponse: body = { "workspace_id": workspace_id, @@ -179,9 +180,9 @@ def __init__(self, client: AsyncAPIClient) -> None: async def create( self, *, - request: Optional[Dict[str, Any]] = None, - response: Optional[Dict[str, Any]] = None, - metadata: Optional[Dict[str, Any]] = None, + request: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + response: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + metadata: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, ) -> Any: body = { "request": request, @@ -206,10 +207,10 @@ def __init__(self, client: AsyncAPIClient) -> None: async def create( self, *, - filters: Optional[Dict[str, Any]] = None, - workspace_id: Optional[str] = None, - description: Optional[str] = None, - requested_data: Optional[List[str]] = None, + filters: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + description: Union[str, NotGiven] = NOT_GIVEN, + requested_data: Union[List[str], NotGiven] = NOT_GIVEN, ) -> LogsExportCreateResponse: body = { "filters": filters, @@ -241,12 +242,12 @@ async def retrieve(self, *, export_id: str) -> LogsExportRetrieveResponse: async def list( self, *, - workspace_id: Optional[str] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, ) -> LogsExportListResponse: query = { "workspace_id": workspace_id, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return await self._get( f"{PortkeyApiPaths.LOGS_EXPORT_API}?{query_string}", @@ -261,10 +262,10 @@ async def list( async def update( self, *, - export_id: Optional[str] = None, - workspace_id: Optional[str] = None, - filters: Optional[Dict[str, Any]] = None, - requested_data: Optional[List[str]] = None, + export_id: Union[str, NotGiven] = NOT_GIVEN, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + filters: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + requested_data: Union[List[str], NotGiven] = NOT_GIVEN, ) -> LogsExportUpdateResponse: body = { "workspace_id": workspace_id, From cfc44bb14c1fc54d1bd070f7b71406e8a7057747 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Fri, 31 Oct 2025 18:52:11 +0530 Subject: [PATCH 06/14] feat: changes in labels --- portkey_ai/api_resources/apis/labels.py | 51 +++++++++++++------------ 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/portkey_ai/api_resources/apis/labels.py b/portkey_ai/api_resources/apis/labels.py index 8f44dea..1ab024e 100644 --- a/portkey_ai/api_resources/apis/labels.py +++ b/portkey_ai/api_resources/apis/labels.py @@ -1,5 +1,6 @@ -from typing import Any, Optional +from typing import Any, Optional, Union from urllib.parse import urlencode +from portkey_ai._vendor.openai import NOT_GIVEN, NotGiven from portkey_ai.api_resources.apis.api_resource import APIResource, AsyncAPIResource from portkey_ai.api_resources.base_client import APIClient, AsyncAPIClient from portkey_ai.api_resources.utils import GenericResponse, PortkeyApiPaths @@ -13,10 +14,10 @@ def create( self, *, name: str, - organization_id: Optional[str] = None, - workspace_id: Optional[str] = None, - description: Optional[str] = None, - color_code: Optional[str] = None, + organization_id: Union[str, NotGiven] = NOT_GIVEN, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + description: Union[str, NotGiven] = NOT_GIVEN, + color_code: Union[str, NotGiven] = NOT_GIVEN, ) -> Any: body = { "name": name, @@ -38,10 +39,10 @@ def create( def list( self, *, - organization_id: Optional[str] = None, - workspace_id: Optional[str] = None, - current_page: Optional[int] = None, - page_size: Optional[int] = None, + organization_id: Union[str, NotGiven] = NOT_GIVEN, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + current_page: Union[int, NotGiven] = NOT_GIVEN, + page_size: Union[int, NotGiven] = NOT_GIVEN, ) -> Any: query = { "organization_id": organization_id, @@ -49,7 +50,7 @@ def list( "current_page": current_page, "page_size": page_size, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return self._get( f"{PortkeyApiPaths.LABELS_API}?{query_string}", @@ -79,9 +80,9 @@ def update( self, label_id: str, *, - name: Optional[str] = None, - description: Optional[str] = None, - color_code: Optional[str] = None, + name: Union[str, NotGiven] = NOT_GIVEN, + description: Union[str, NotGiven] = NOT_GIVEN, + color_code: Union[str, NotGiven] = NOT_GIVEN, ) -> Any: body = { "name": name, @@ -121,10 +122,10 @@ async def create( self, *, name: str, - organization_id: Optional[str] = None, - workspace_id: Optional[str] = None, - description: Optional[str] = None, - color_code: Optional[str] = None, + organization_id: Union[str, NotGiven] = NOT_GIVEN, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + description: Union[str, NotGiven] = NOT_GIVEN, + color_code: Union[str, NotGiven] = NOT_GIVEN, ) -> Any: body = { "name": name, @@ -146,10 +147,10 @@ async def create( async def list( self, *, - organization_id: Optional[str] = None, - workspace_id: Optional[str] = None, - current_page: Optional[int] = None, - page_size: Optional[int] = None, + organization_id: Union[str, NotGiven] = NOT_GIVEN, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + current_page: Union[int, NotGiven] = NOT_GIVEN, + page_size: Union[int, NotGiven] = NOT_GIVEN, ) -> Any: query = { "organization_id": organization_id, @@ -157,7 +158,7 @@ async def list( "current_page": current_page, "page_size": page_size, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return await self._get( f"{PortkeyApiPaths.LABELS_API}?{query_string}", @@ -187,9 +188,9 @@ async def update( self, label_id: str, *, - name: Optional[str] = None, - description: Optional[str] = None, - color_code: Optional[str] = None, + name: Union[str, NotGiven] = NOT_GIVEN, + description: Union[str, NotGiven] = NOT_GIVEN, + color_code: Union[str, NotGiven] = NOT_GIVEN, ) -> Any: body = { "name": name, From 25b213c09a33c135495bc97a451ee4e6dd9ca4e1 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Fri, 31 Oct 2025 18:54:57 +0530 Subject: [PATCH 07/14] feat: changes in collections --- portkey_ai/api_resources/apis/collections.py | 35 ++++++++++---------- portkey_ai/api_resources/apis/labels.py | 2 +- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/portkey_ai/api_resources/apis/collections.py b/portkey_ai/api_resources/apis/collections.py index f2d3642..6062a55 100644 --- a/portkey_ai/api_resources/apis/collections.py +++ b/portkey_ai/api_resources/apis/collections.py @@ -1,5 +1,6 @@ -from typing import Any, Optional +from typing import Any, Union from urllib.parse import urlencode +from portkey_ai._vendor.openai import NOT_GIVEN, NotGiven from portkey_ai.api_resources.apis.api_resource import APIResource, AsyncAPIResource from portkey_ai.api_resources.base_client import APIClient, AsyncAPIClient from portkey_ai.api_resources.utils import GenericResponse, PortkeyApiPaths @@ -12,8 +13,8 @@ def __init__(self, client: APIClient) -> None: def create( self, name: str, - workspace_id: Optional[str] = None, - parent_collection_id: Optional[str] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + parent_collection_id: Union[str, NotGiven] = NOT_GIVEN, ) -> Any: body = { "name": name, @@ -33,10 +34,10 @@ def create( def list( self, *, - workspace_id: Optional[str] = None, - current_page: Optional[int] = None, - page_size: Optional[int] = None, - search: Optional[str] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + current_page: Union[int, NotGiven] = NOT_GIVEN, + page_size: Union[int, NotGiven] = NOT_GIVEN, + search: Union[str, NotGiven] = NOT_GIVEN, ) -> Any: query = { "workspace_id": workspace_id, @@ -44,7 +45,7 @@ def list( "page_size": page_size, "search": search, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return self._get( f"{PortkeyApiPaths.COLLECTIONS_API}?{query_string}", @@ -74,7 +75,7 @@ def update( self, collection_id: str, *, - name: Optional[str] = None, + name: Union[str, NotGiven] = NOT_GIVEN, ) -> Any: body = { "name": name, @@ -111,8 +112,8 @@ def __init__(self, client: AsyncAPIClient) -> None: async def create( self, name: str, - workspace_id: Optional[str] = None, - parent_collection_id: Optional[str] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + parent_collection_id: Union[str, NotGiven] = NOT_GIVEN, ) -> Any: body = { "name": name, @@ -132,10 +133,10 @@ async def create( async def list( self, *, - workspace_id: Optional[str] = None, - current_page: Optional[int] = None, - page_size: Optional[int] = None, - search: Optional[str] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + current_page: Union[int, NotGiven] = NOT_GIVEN, + page_size: Union[int, NotGiven] = NOT_GIVEN, + search: Union[str, NotGiven] = NOT_GIVEN, ) -> Any: query = { "workspace_id": workspace_id, @@ -143,7 +144,7 @@ async def list( "page_size": page_size, "search": search, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return await self._get( f"{PortkeyApiPaths.COLLECTIONS_API}?{query_string}", @@ -173,7 +174,7 @@ async def update( self, collection_id: str, *, - name: Optional[str] = None, + name: Union[str, NotGiven] = NOT_GIVEN, ) -> Any: body = { "name": name, diff --git a/portkey_ai/api_resources/apis/labels.py b/portkey_ai/api_resources/apis/labels.py index 1ab024e..057c628 100644 --- a/portkey_ai/api_resources/apis/labels.py +++ b/portkey_ai/api_resources/apis/labels.py @@ -1,4 +1,4 @@ -from typing import Any, Optional, Union +from typing import Any, Union from urllib.parse import urlencode from portkey_ai._vendor.openai import NOT_GIVEN, NotGiven from portkey_ai.api_resources.apis.api_resource import APIResource, AsyncAPIResource From a0c5304ebe838a71234f7f2c48df4f0984df14bb Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Fri, 31 Oct 2025 19:14:16 +0530 Subject: [PATCH 08/14] feat: changes in integrations --- portkey_ai/api_resources/apis/integrations.py | 83 ++++++++++--------- 1 file changed, 42 insertions(+), 41 deletions(-) diff --git a/portkey_ai/api_resources/apis/integrations.py b/portkey_ai/api_resources/apis/integrations.py index c7ac790..4a018fe 100644 --- a/portkey_ai/api_resources/apis/integrations.py +++ b/portkey_ai/api_resources/apis/integrations.py @@ -1,4 +1,5 @@ -from typing import Any, Dict, List, Literal, Optional +from typing import Any, Dict, List, Literal, Optional, Union +from portkey_ai._vendor.openai import NOT_GIVEN, NotGiven from portkey_ai.api_resources.base_client import APIClient, AsyncAPIClient from urllib.parse import urlencode from portkey_ai.api_resources.apis.api_resource import APIResource, AsyncAPIResource @@ -22,13 +23,13 @@ def __init__(self, client: APIClient) -> None: def create( self, *, - name: Optional[str] = None, - description: Optional[str] = None, - key: Optional[str] = None, - ai_provider_id: Optional[str] = None, - workspace_id: Optional[str] = None, - slug: Optional[str] = None, - configurations: Optional[Dict[str, Any]] = None, + name: Union[str, NotGiven] = NOT_GIVEN, + description: Union[str, NotGiven] = NOT_GIVEN, + key: Union[str, NotGiven] = NOT_GIVEN, + ai_provider_id: Union[str, NotGiven] = NOT_GIVEN, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + slug: Union[str, NotGiven] = NOT_GIVEN, + configurations: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, **kwargs: Any, ) -> IntegrationCreateResponse: body = { @@ -56,8 +57,8 @@ def list( *, current_page: Optional[int] = 0, page_size: Optional[int] = 100, - workspace_id: Optional[str] = None, - type: Optional[Literal["workspace", "organisation", "all"]] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + type: Union[Literal["workspace", "organisation", "all"], NotGiven] = NOT_GIVEN, ) -> IntegrationListResponse: query = { "current_page": current_page, @@ -65,7 +66,7 @@ def list( "workspace_id": workspace_id, "type": type, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return self._get( f"{PortkeyApiPaths.INTEGRATIONS_API}?{query_string}", @@ -92,10 +93,10 @@ def update( self, *, slug: str, - name: Optional[str] = None, - description: Optional[str] = None, - key: Optional[str] = None, - configurations: Optional[Dict[str, Any]] = None, + name: Union[str, NotGiven] = NOT_GIVEN, + description: Union[str, NotGiven] = NOT_GIVEN, + key: Union[str, NotGiven] = NOT_GIVEN, + configurations: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, **kwargs: Any, ) -> GenericResponse: body = { @@ -154,9 +155,9 @@ def update( self, *, slug: str, - global_workspace_access: Optional[Dict[str, Any]] = None, - override_existing_workspaces_access: Optional[bool] = None, - workspaces: Optional[List[Dict[str, Any]]] = None, + global_workspace_access: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + override_existing_workspaces_access: Union[bool, NotGiven] = NOT_GIVEN, + workspaces: Union[List[Dict[str, Any]], NotGiven] = NOT_GIVEN, **kwargs: Any, ) -> GenericResponse: body = { @@ -199,8 +200,8 @@ def update( self, *, slug: str, - allow_all_models: Optional[bool] = None, - models: Optional[List[Dict[str, Any]]] = None, + allow_all_models: Union[bool, NotGiven] = NOT_GIVEN, + models: Union[List[Dict[str, Any]], NotGiven] = NOT_GIVEN, **kwargs: Any, ) -> GenericResponse: body = { @@ -227,7 +228,7 @@ def delete( query = { "slugs": slugs, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return self._delete( f"{PortkeyApiPaths.INTEGRATIONS_API}/{slug}/models?{query_string}", @@ -249,13 +250,13 @@ def __init__(self, client: AsyncAPIClient) -> None: async def create( self, *, - name: Optional[str] = None, - description: Optional[str] = None, - key: Optional[str] = None, - ai_provider_id: Optional[str] = None, - workspace_id: Optional[str] = None, - slug: Optional[str] = None, - configurations: Optional[Dict[str, Any]] = None, + name: Union[str, NotGiven] = NOT_GIVEN, + description: Union[str, NotGiven] = NOT_GIVEN, + key: Union[str, NotGiven] = NOT_GIVEN, + ai_provider_id: Union[str, NotGiven] = NOT_GIVEN, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + slug: Union[str, NotGiven] = NOT_GIVEN, + configurations: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, **kwargs: Any, ) -> IntegrationCreateResponse: body = { @@ -283,8 +284,8 @@ async def list( *, current_page: Optional[int] = 0, page_size: Optional[int] = 100, - workspace_id: Optional[str] = None, - type: Optional[Literal["workspace", "organisation", "all"]] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + type: Union[Literal["workspace", "organisation", "all"], NotGiven] = NOT_GIVEN, ) -> IntegrationListResponse: query = { "current_page": current_page, @@ -292,7 +293,7 @@ async def list( "workspace_id": workspace_id, "type": type, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return await self._get( f"{PortkeyApiPaths.INTEGRATIONS_API}?{query_string}", @@ -319,10 +320,10 @@ async def update( self, *, slug: str, - name: Optional[str] = None, - description: Optional[str] = None, - key: Optional[str] = None, - configurations: Optional[Dict[str, Any]] = None, + name: Union[str, NotGiven] = NOT_GIVEN, + description: Union[str, NotGiven] = NOT_GIVEN, + key: Union[str, NotGiven] = NOT_GIVEN, + configurations: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, **kwargs: Any, ) -> GenericResponse: body = { @@ -381,9 +382,9 @@ async def update( self, *, slug: str, - global_workspace_access: Optional[Dict[str, Any]] = None, - override_existing_workspaces_access: Optional[bool] = None, - workspaces: Optional[List[Dict[str, Any]]] = None, + global_workspace_access: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + override_existing_workspaces_access: Union[bool, NotGiven] = NOT_GIVEN, + workspaces: Union[List[Dict[str, Any]], NotGiven] = NOT_GIVEN, **kwargs: Any, ) -> GenericResponse: body = { @@ -426,8 +427,8 @@ async def update( self, *, slug: str, - allow_all_models: Optional[bool] = None, - models: Optional[List[Dict[str, Any]]] = None, + allow_all_models: Union[bool, NotGiven] = NOT_GIVEN, + models: Union[List[Dict[str, Any]], NotGiven] = NOT_GIVEN, **kwargs: Any, ) -> GenericResponse: body = { @@ -454,7 +455,7 @@ async def delete( query = { "slugs": slugs, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return await self._delete( f"{PortkeyApiPaths.INTEGRATIONS_API}/{slug}/models?{query_string}", From 8dfe38163b905c4757a239df3058391e73ddc515 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Fri, 31 Oct 2025 19:16:50 +0530 Subject: [PATCH 09/14] feat: changes in providers --- portkey_ai/api_resources/apis/providers.py | 83 +++++++++++----------- 1 file changed, 42 insertions(+), 41 deletions(-) diff --git a/portkey_ai/api_resources/apis/providers.py b/portkey_ai/api_resources/apis/providers.py index 6787e7c..3313f03 100644 --- a/portkey_ai/api_resources/apis/providers.py +++ b/portkey_ai/api_resources/apis/providers.py @@ -1,4 +1,5 @@ -from typing import Any, Dict, Optional +from typing import Any, Dict, Optional, Union +from portkey_ai._vendor.openai import NOT_GIVEN, NotGiven from portkey_ai.api_resources.base_client import APIClient, AsyncAPIClient from urllib.parse import urlencode from portkey_ai.api_resources.apis.api_resource import APIResource, AsyncAPIResource @@ -21,12 +22,12 @@ def create( *, name: str, integration_id: str, - workspace_id: Optional[str] = None, - slug: Optional[str] = None, - note: Optional[str] = None, - usage_limits: Optional[Dict[str, Any]] = None, - rate_limits: Optional[Dict[str, Any]] = None, - expires_at: Optional[str] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + slug: Union[str, NotGiven] = NOT_GIVEN, + note: Union[str, NotGiven] = NOT_GIVEN, + usage_limits: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + rate_limits: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + expires_at: Union[str, NotGiven] = NOT_GIVEN, **kwargs: Any, ) -> ProviderCreateResponse: body = { @@ -55,14 +56,14 @@ def list( *, current_page: Optional[int] = 0, page_size: Optional[int] = 50, - workspace_id: Optional[str] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, ) -> ProviderListResponse: query = { "current_page": current_page, "page_size": page_size, "workspace_id": workspace_id, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return self._get( f"{PortkeyApiPaths.PROVIDERS_API}?{query_string}", @@ -78,12 +79,12 @@ def retrieve( self, *, slug: str, - workspace_id: Optional[str] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, ) -> ProviderDetailResponse: query = { "workspace_id": workspace_id, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) path = f"{PortkeyApiPaths.PROVIDERS_API}/{slug}" if query_string: @@ -102,13 +103,13 @@ def update( self, *, slug: str, - workspace_id: Optional[str] = None, - name: Optional[str] = None, - note: Optional[str] = None, - usage_limits: Optional[Dict[str, Any]] = None, - rate_limits: Optional[Dict[str, Any]] = None, - expires_at: Optional[str] = None, - reset_usage: Optional[bool] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + name: Union[str, NotGiven] = NOT_GIVEN, + note: Union[str, NotGiven] = NOT_GIVEN, + usage_limits: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + rate_limits: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + expires_at: Union[str, NotGiven] = NOT_GIVEN, + reset_usage: Union[bool, NotGiven] = NOT_GIVEN, **kwargs: Any, ) -> ProviderUpdateResponse: body = { @@ -123,7 +124,7 @@ def update( query = { "workspace_id": workspace_id, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) path = f"{PortkeyApiPaths.PROVIDERS_API}/{slug}" if query_string: @@ -142,12 +143,12 @@ def delete( self, *, slug: str, - workspace_id: Optional[str] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, ) -> GenericResponse: query = { "workspace_id": workspace_id, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) path = f"{PortkeyApiPaths.PROVIDERS_API}/{slug}" if query_string: @@ -172,12 +173,12 @@ async def create( *, name: str, integration_id: str, - workspace_id: Optional[str] = None, - slug: Optional[str] = None, - note: Optional[str] = None, - usage_limits: Optional[Dict[str, Any]] = None, - rate_limits: Optional[Dict[str, Any]] = None, - expires_at: Optional[str] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + slug: Union[str, NotGiven] = NOT_GIVEN, + note: Union[str, NotGiven] = NOT_GIVEN, + usage_limits: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + rate_limits: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + expires_at: Union[str, NotGiven] = NOT_GIVEN, **kwargs: Any, ) -> ProviderCreateResponse: body = { @@ -206,14 +207,14 @@ async def list( *, current_page: Optional[int] = 0, page_size: Optional[int] = 50, - workspace_id: Optional[str] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, ) -> ProviderListResponse: query = { "current_page": current_page, "page_size": page_size, "workspace_id": workspace_id, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return await self._get( f"{PortkeyApiPaths.PROVIDERS_API}?{query_string}", @@ -229,12 +230,12 @@ async def retrieve( self, *, slug: str, - workspace_id: Optional[str] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, ) -> ProviderDetailResponse: query = { "workspace_id": workspace_id, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) path = f"{PortkeyApiPaths.PROVIDERS_API}/{slug}" if query_string: @@ -253,13 +254,13 @@ async def update( self, *, slug: str, - workspace_id: Optional[str] = None, - name: Optional[str] = None, - note: Optional[str] = None, - usage_limits: Optional[Dict[str, Any]] = None, - rate_limits: Optional[Dict[str, Any]] = None, - expires_at: Optional[str] = None, - reset_usage: Optional[bool] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + name: Union[str, NotGiven] = NOT_GIVEN, + note: Union[str, NotGiven] = NOT_GIVEN, + usage_limits: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + rate_limits: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + expires_at: Union[str, NotGiven] = NOT_GIVEN, + reset_usage: Union[bool, NotGiven] = NOT_GIVEN, **kwargs: Any, ) -> ProviderUpdateResponse: body = { @@ -274,7 +275,7 @@ async def update( query = { "workspace_id": workspace_id, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) path = f"{PortkeyApiPaths.PROVIDERS_API}/{slug}" if query_string: @@ -293,12 +294,12 @@ async def delete( self, *, slug: str, - workspace_id: Optional[str] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, ) -> GenericResponse: query = { "workspace_id": workspace_id, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) path = f"{PortkeyApiPaths.PROVIDERS_API}/{slug}" if query_string: From c015ddad8b5475f297190f0e29b5c5f279f1fdff Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Fri, 31 Oct 2025 19:18:47 +0530 Subject: [PATCH 10/14] feat: changes in guardrails --- portkey_ai/api_resources/apis/guardrails.py | 35 +++++++++++---------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/portkey_ai/api_resources/apis/guardrails.py b/portkey_ai/api_resources/apis/guardrails.py index 9e6c18a..b4c940e 100644 --- a/portkey_ai/api_resources/apis/guardrails.py +++ b/portkey_ai/api_resources/apis/guardrails.py @@ -1,4 +1,5 @@ -from typing import Any, Dict, List, Optional +from typing import Any, Dict, List, Optional, Union +from portkey_ai._vendor.openai import NOT_GIVEN, NotGiven from portkey_ai.api_resources.base_client import APIClient, AsyncAPIClient from urllib.parse import urlencode from portkey_ai.api_resources.apis.api_resource import APIResource, AsyncAPIResource @@ -22,8 +23,8 @@ def create( name: str, checks: List[Dict[str, Any]], actions: Dict[str, Any], - workspace_id: Optional[str] = None, - organisation_id: Optional[str] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + organisation_id: Union[str, NotGiven] = NOT_GIVEN, **kwargs: Any, ) -> GuardrailCreateResponse: body = { @@ -47,8 +48,8 @@ def create( def list( self, *, - workspace_id: Optional[str] = None, - organisation_id: Optional[str] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + organisation_id: Union[str, NotGiven] = NOT_GIVEN, page_size: Optional[int] = 100, current_page: Optional[int] = 0, ) -> GuardrailListResponse: @@ -58,7 +59,7 @@ def list( "page_size": page_size, "current_page": current_page, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return self._get( f"{PortkeyApiPaths.GUARDRAILS_API}?{query_string}", @@ -89,9 +90,9 @@ def update( self, *, guardrail_id: str, - name: Optional[str] = None, - checks: Optional[List[Dict[str, Any]]] = None, - actions: Optional[Dict[str, Any]] = None, + name: Union[str, NotGiven] = NOT_GIVEN, + checks: Union[List[Dict[str, Any]], NotGiven] = NOT_GIVEN, + actions: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, **kwargs: Any, ) -> GuardrailUpdateResponse: body = { @@ -136,8 +137,8 @@ async def create( name: str, checks: List[Dict[str, Any]], actions: Dict[str, Any], - workspace_id: Optional[str] = None, - organisation_id: Optional[str] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + organisation_id: Union[str, NotGiven] = NOT_GIVEN, **kwargs: Any, ) -> GuardrailCreateResponse: body = { @@ -161,8 +162,8 @@ async def create( async def list( self, *, - workspace_id: Optional[str] = None, - organisation_id: Optional[str] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + organisation_id: Union[str, NotGiven] = NOT_GIVEN, page_size: Optional[int] = 100, current_page: Optional[int] = 0, ) -> GuardrailListResponse: @@ -172,7 +173,7 @@ async def list( "page_size": page_size, "current_page": current_page, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return await self._get( f"{PortkeyApiPaths.GUARDRAILS_API}?{query_string}", @@ -203,9 +204,9 @@ async def update( self, *, guardrail_id: str, - name: Optional[str] = None, - checks: Optional[List[Dict[str, Any]]] = None, - actions: Optional[Dict[str, Any]] = None, + name: Union[str, NotGiven] = NOT_GIVEN, + checks: Union[List[Dict[str, Any]], NotGiven] = NOT_GIVEN, + actions: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, **kwargs: Any, ) -> GuardrailUpdateResponse: body = { From 59fdd8229c20ccd16755ad8c7b38b29a0324c219 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Mon, 3 Nov 2025 13:39:15 +0530 Subject: [PATCH 11/14] feat: changes in configs --- portkey_ai/api_resources/apis/configs.py | 54 +++++++++++++----------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/portkey_ai/api_resources/apis/configs.py b/portkey_ai/api_resources/apis/configs.py index b919dbf..456e278 100644 --- a/portkey_ai/api_resources/apis/configs.py +++ b/portkey_ai/api_resources/apis/configs.py @@ -1,4 +1,5 @@ -from typing import Any, Dict, Optional +from typing import Any, Dict, Optional, Union +from portkey_ai._vendor.openai import NOT_GIVEN, NotGiven from portkey_ai.api_resources.base_client import APIClient, AsyncAPIClient from urllib.parse import urlencode from portkey_ai.api_resources.apis.api_resource import APIResource, AsyncAPIResource @@ -19,10 +20,10 @@ def __init__(self, client: APIClient) -> None: def create( self, *, - name: Optional[str] = None, - config: Optional[Dict[str, Any]] = None, - is_default: Optional[int] = None, - workspace_id: Optional[str] = None, + name: Union[str, NotGiven] = NOT_GIVEN, + config: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + is_default: Union[int, NotGiven] = NOT_GIVEN, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, ) -> ConfigAddResponse: body = { "name": name, @@ -54,12 +55,12 @@ def retrieve(self, *, slug: Optional[str]) -> ConfigGetResponse: def list( self, *, - workspace_id: Optional[str] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, ) -> ConfigListResponse: query = { "workspace_id": workspace_id, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return self._get( f"{PortkeyApiPaths.CONFIG_API}?{query_string}", @@ -74,10 +75,10 @@ def list( def update( self, *, - slug: Optional[str] = None, - name: Optional[str] = None, - config: Optional[Dict[str, Any]] = None, - status: Optional[str] = None, + slug: Union[str, NotGiven] = NOT_GIVEN, + name: Union[str, NotGiven] = NOT_GIVEN, + config: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + status: Union[str, NotGiven] = NOT_GIVEN, ) -> ConfigUpdateResponse: body = { "slug": slug, @@ -95,7 +96,12 @@ def update( headers={}, ) - def delete(self, *, id: Optional[str] = None, slug: Optional[str] = None) -> Any: + def delete( + self, + *, + id: Union[str, NotGiven] = NOT_GIVEN, + slug: Union[str, NotGiven] = NOT_GIVEN, + ) -> Any: config_slug = None if id: import warnings @@ -128,10 +134,10 @@ def __init__(self, client: AsyncAPIClient) -> None: async def create( self, *, - name: Optional[str] = None, - config: Optional[Dict[str, Any]] = None, - is_default: Optional[int] = None, - workspace_id: Optional[str] = None, + name: Union[str, NotGiven] = NOT_GIVEN, + config: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + is_default: Union[int, NotGiven] = NOT_GIVEN, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, ) -> ConfigAddResponse: body = { "name": name, @@ -163,12 +169,12 @@ async def retrieve(self, *, slug: Optional[str]) -> ConfigGetResponse: async def list( self, *, - workspace_id: Optional[str] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, ) -> ConfigListResponse: query = { "workspace_id": workspace_id, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return await self._get( f"{PortkeyApiPaths.CONFIG_API}?{query_string}", @@ -183,10 +189,10 @@ async def list( async def update( self, *, - slug: Optional[str] = None, - name: Optional[str] = None, - config: Optional[Dict[str, Any]] = None, - status: Optional[str] = None, + slug: Union[str, NotGiven] = NOT_GIVEN, + name: Union[str, NotGiven] = NOT_GIVEN, + config: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + status: Union[str, NotGiven] = NOT_GIVEN, ) -> ConfigUpdateResponse: body = { "slug": slug, @@ -207,8 +213,8 @@ async def update( async def delete( self, *, - id: Optional[str] = None, - slug: Optional[str] = None, + id: Union[str, NotGiven] = NOT_GIVEN, + slug: Union[str, NotGiven] = NOT_GIVEN, ) -> Any: config_slug = None if id: From e569013479dcca3b2783052896b16ef755bbc541 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Mon, 3 Nov 2025 13:57:06 +0530 Subject: [PATCH 12/14] feat: changes in prompts --- portkey_ai/api_resources/apis/generation.py | 263 ++++++++++---------- 1 file changed, 132 insertions(+), 131 deletions(-) diff --git a/portkey_ai/api_resources/apis/generation.py b/portkey_ai/api_resources/apis/generation.py index 58cfcff..0015f1f 100644 --- a/portkey_ai/api_resources/apis/generation.py +++ b/portkey_ai/api_resources/apis/generation.py @@ -1,7 +1,8 @@ from __future__ import annotations from urllib.parse import urlencode import warnings -from typing import Dict, List, Literal, Optional, Union, Mapping, Any, overload +from typing import Dict, List, Literal, Union, Mapping, Any, overload +from portkey_ai._vendor.openai import NOT_GIVEN, NotGiven from portkey_ai.api_resources.base_client import APIClient, AsyncAPIClient from portkey_ai.api_resources.types.generation_type import ( PromptCompletion, @@ -26,8 +27,8 @@ def create( self, *, prompt_id: str, - config: Optional[Union[Mapping, str]] = None, - variables: Optional[Mapping[str, Any]] = None, + config: Union[Mapping, str, NotGiven] = NOT_GIVEN, + variables: Union[Mapping[str, Any], NotGiven] = NOT_GIVEN, ) -> Union[GenericResponse, Stream[GenericResponse]]: warning_message = "This API has been deprecated. Please use the Prompt API for the saved prompt." # noqa: E501 warnings.warn( @@ -35,7 +36,7 @@ def create( DeprecationWarning, stacklevel=2, ) - if config is None: + if config is NOT_GIVEN: config = retrieve_config() body = {"variables": variables} response = self._post( @@ -59,8 +60,8 @@ async def create( self, *, prompt_id: str, - config: Optional[Union[Mapping, str]] = None, - variables: Optional[Mapping[str, Any]] = None, + config: Union[Mapping, str, NotGiven] = NOT_GIVEN, + variables: Union[Mapping[str, Any], NotGiven] = NOT_GIVEN, ) -> Union[GenericResponse, AsyncStream[GenericResponse]]: warning_message = "This API has been deprecated. Please use the Prompt API for the saved prompt." # noqa: E501 warnings.warn( @@ -68,7 +69,7 @@ async def create( DeprecationWarning, stacklevel=2, ) - if config is None: + if config is NOT_GIVEN: config = retrieve_config() body = {"variables": variables} response = await self._post( @@ -99,10 +100,10 @@ def render( prompt_id: str, variables: Mapping[str, Any], stream: bool = False, - temperature: Optional[float] = None, - max_tokens: Optional[int] = None, - top_k: Optional[int] = None, - top_p: Optional[float] = None, + temperature: Union[float, NotGiven] = NOT_GIVEN, + max_tokens: Union[int, NotGiven] = NOT_GIVEN, + top_k: Union[int, NotGiven] = NOT_GIVEN, + top_p: Union[float, NotGiven] = NOT_GIVEN, **kwargs, ) -> PromptRender: """Prompt render Method""" @@ -132,13 +133,13 @@ def create( collection_id: str, string: str, parameters: Dict[str, Any], - virtual_key: Optional[str] = None, - model: Optional[str] = None, - functions: Optional[List[Any]] = None, - tools: Optional[List[Any]] = None, - tool_choice: Optional[Dict[str, Any]] = None, - version_description: Optional[str] = None, - template_metadata: Optional[Dict[str, Any]] = None, + virtual_key: Union[str, NotGiven] = NOT_GIVEN, + model: Union[str, NotGiven] = NOT_GIVEN, + functions: Union[List[Any], NotGiven] = NOT_GIVEN, + tools: Union[List[Any], NotGiven] = NOT_GIVEN, + tool_choice: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + version_description: Union[str, NotGiven] = NOT_GIVEN, + template_metadata: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, ) -> Any: body = { "name": name, @@ -166,11 +167,11 @@ def create( def list( self, *, - collection_id: Optional[str] = None, - workspace_id: Optional[str] = None, - current_page: Optional[int] = None, - page_size: Optional[int] = None, - search: Optional[str] = None, + collection_id: Union[str, NotGiven] = NOT_GIVEN, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + current_page: Union[int, NotGiven] = NOT_GIVEN, + page_size: Union[int, NotGiven] = NOT_GIVEN, + search: Union[str, NotGiven] = NOT_GIVEN, ) -> Any: query = { "collection_id": collection_id, @@ -179,7 +180,7 @@ def list( "page_size": page_size, "search": search, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return self._get( f"{PortkeyApiPaths.PROMPTS_API}?{query_string}", @@ -209,17 +210,17 @@ def update( self, prompt_slug: str, *, - name: Optional[str] = None, - collection_id: Optional[str] = None, - string: Optional[str] = None, - parameters: Optional[Dict[str, Any]] = None, - virtual_key: Optional[str] = None, - model: Optional[str] = None, - functions: Optional[List[Any]] = None, - tools: Optional[List[Any]] = None, - tool_choice: Optional[Dict[str, Any]] = None, - version_description: Optional[str] = None, - template_metadata: Optional[Dict[str, Any]] = None, + name: Union[str, NotGiven] = NOT_GIVEN, + collection_id: Union[str, NotGiven] = NOT_GIVEN, + string: Union[str, NotGiven] = NOT_GIVEN, + parameters: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + virtual_key: Union[str, NotGiven] = NOT_GIVEN, + model: Union[str, NotGiven] = NOT_GIVEN, + functions: Union[List[Any], NotGiven] = NOT_GIVEN, + tools: Union[List[Any], NotGiven] = NOT_GIVEN, + tool_choice: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + version_description: Union[str, NotGiven] = NOT_GIVEN, + template_metadata: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, ) -> Any: body = { "name": name, @@ -293,10 +294,10 @@ async def render( prompt_id: str, variables: Mapping[str, Any], stream: bool = False, - temperature: Optional[float] = None, - max_tokens: Optional[int] = None, - top_k: Optional[int] = None, - top_p: Optional[float] = None, + temperature: Union[float, NotGiven] = NOT_GIVEN, + max_tokens: Union[int, NotGiven] = NOT_GIVEN, + top_k: Union[int, NotGiven] = NOT_GIVEN, + top_p: Union[float, NotGiven] = NOT_GIVEN, **kwargs, ) -> PromptRender: """Prompt render Method""" @@ -326,13 +327,13 @@ async def create( collection_id: str, string: str, parameters: Dict[str, Any], - virtual_key: Optional[str] = None, - model: Optional[str] = None, - functions: Optional[List[Any]] = None, - tools: Optional[List[Any]] = None, - tool_choice: Optional[Dict[str, Any]] = None, - version_description: Optional[str] = None, - template_metadata: Optional[Dict[str, Any]] = None, + virtual_key: Union[str, NotGiven] = NOT_GIVEN, + model: Union[str, NotGiven] = NOT_GIVEN, + functions: Union[List[Any], NotGiven] = NOT_GIVEN, + tools: Union[List[Any], NotGiven] = NOT_GIVEN, + tool_choice: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + version_description: Union[str, NotGiven] = NOT_GIVEN, + template_metadata: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, ) -> Any: body = { "name": name, @@ -360,11 +361,11 @@ async def create( async def list( self, *, - collection_id: Optional[str] = None, - workspace_id: Optional[str] = None, - current_page: Optional[int] = None, - page_size: Optional[int] = None, - search: Optional[str] = None, + collection_id: Union[str, NotGiven] = NOT_GIVEN, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + current_page: Union[int, NotGiven] = NOT_GIVEN, + page_size: Union[int, NotGiven] = NOT_GIVEN, + search: Union[str, NotGiven] = NOT_GIVEN, ) -> Any: query = { "collection_id": collection_id, @@ -373,7 +374,7 @@ async def list( "page_size": page_size, "search": search, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return await self._get( f"{PortkeyApiPaths.PROMPTS_API}?{query_string}", @@ -403,17 +404,17 @@ async def update( self, prompt_slug: str, *, - name: Optional[str] = None, - collection_id: Optional[str] = None, - string: Optional[str] = None, - parameters: Optional[Dict[str, Any]] = None, - virtual_key: Optional[str] = None, - model: Optional[str] = None, - functions: Optional[List[Any]] = None, - tools: Optional[List[Any]] = None, - tool_choice: Optional[Dict[str, Any]] = None, - version_description: Optional[str] = None, - template_metadata: Optional[Dict[str, Any]] = None, + name: Union[str, NotGiven] = NOT_GIVEN, + collection_id: Union[str, NotGiven] = NOT_GIVEN, + string: Union[str, NotGiven] = NOT_GIVEN, + parameters: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + virtual_key: Union[str, NotGiven] = NOT_GIVEN, + model: Union[str, NotGiven] = NOT_GIVEN, + functions: Union[List[Any], NotGiven] = NOT_GIVEN, + tools: Union[List[Any], NotGiven] = NOT_GIVEN, + tool_choice: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, + version_description: Union[str, NotGiven] = NOT_GIVEN, + template_metadata: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, ) -> Any: body = { "name": name, @@ -481,13 +482,13 @@ def create( self, *, prompt_id: str, - variables: Optional[Mapping[str, Any]] = None, - config: Optional[Union[Mapping, str]] = None, + variables: Union[Mapping[str, Any], NotGiven] = NOT_GIVEN, + config: Union[Mapping, str, NotGiven] = NOT_GIVEN, stream: Literal[True], - temperature: Optional[float] = None, - max_tokens: Optional[int] = None, - top_k: Optional[int] = None, - top_p: Optional[float] = None, + temperature: Union[float, NotGiven] = NOT_GIVEN, + max_tokens: Union[int, NotGiven] = NOT_GIVEN, + top_k: Union[int, NotGiven] = NOT_GIVEN, + top_p: Union[float, NotGiven] = NOT_GIVEN, extra_headers: Mapping[str, str] = {}, **kwargs, ) -> Stream[PromptCompletionChunk]: @@ -498,13 +499,13 @@ def create( self, *, prompt_id: str, - variables: Optional[Mapping[str, Any]] = None, - config: Optional[Union[Mapping, str]] = None, + variables: Union[Mapping[str, Any], NotGiven] = NOT_GIVEN, + config: Union[Mapping, str, NotGiven] = NOT_GIVEN, stream: Literal[False] = False, - temperature: Optional[float] = None, - max_tokens: Optional[int] = None, - top_k: Optional[int] = None, - top_p: Optional[float] = None, + temperature: Union[float, NotGiven] = NOT_GIVEN, + max_tokens: Union[int, NotGiven] = NOT_GIVEN, + top_k: Union[int, NotGiven] = NOT_GIVEN, + top_p: Union[float, NotGiven] = NOT_GIVEN, extra_headers: Mapping[str, str] = {}, **kwargs, ) -> PromptCompletion: @@ -515,13 +516,13 @@ def create( self, *, prompt_id: str, - variables: Optional[Mapping[str, Any]] = None, - config: Optional[Union[Mapping, str]] = None, + variables: Union[Mapping[str, Any], NotGiven] = NOT_GIVEN, + config: Union[Mapping, str, NotGiven] = NOT_GIVEN, stream: bool = False, - temperature: Optional[float] = None, - max_tokens: Optional[int] = None, - top_k: Optional[int] = None, - top_p: Optional[float] = None, + temperature: Union[float, NotGiven] = NOT_GIVEN, + max_tokens: Union[int, NotGiven] = NOT_GIVEN, + top_k: Union[int, NotGiven] = NOT_GIVEN, + top_p: Union[float, NotGiven] = NOT_GIVEN, extra_headers: Mapping[str, str] = {}, **kwargs, ) -> Union[PromptCompletion, Stream[PromptCompletionChunk]]: @@ -531,18 +532,18 @@ def create( self, *, prompt_id: str, - variables: Optional[Mapping[str, Any]] = None, - config: Optional[Union[Mapping, str]] = None, + variables: Union[Mapping[str, Any], NotGiven] = NOT_GIVEN, + config: Union[Mapping, str, NotGiven] = NOT_GIVEN, stream: bool = False, - temperature: Optional[float] = None, - max_tokens: Optional[int] = None, - top_k: Optional[int] = None, - top_p: Optional[float] = None, + temperature: Union[float, NotGiven] = NOT_GIVEN, + max_tokens: Union[int, NotGiven] = NOT_GIVEN, + top_k: Union[int, NotGiven] = NOT_GIVEN, + top_p: Union[float, NotGiven] = NOT_GIVEN, extra_headers: Mapping[str, str] = {}, **kwargs, ) -> Union[PromptCompletion, Stream[PromptCompletionChunk]]: """Prompt completions Method""" - if config is None: + if config is NOT_GIVEN: config = retrieve_config() body = { "variables": variables, @@ -574,13 +575,13 @@ async def create( self, *, prompt_id: str, - variables: Optional[Mapping[str, Any]] = None, - config: Optional[Union[Mapping, str]] = None, + variables: Union[Mapping[str, Any], NotGiven] = NOT_GIVEN, + config: Union[Mapping, str, NotGiven] = NOT_GIVEN, stream: Literal[True], - temperature: Optional[float] = None, - max_tokens: Optional[int] = None, - top_k: Optional[int] = None, - top_p: Optional[float] = None, + temperature: Union[float, NotGiven] = NOT_GIVEN, + max_tokens: Union[int, NotGiven] = NOT_GIVEN, + top_k: Union[int, NotGiven] = NOT_GIVEN, + top_p: Union[float, NotGiven] = NOT_GIVEN, extra_headers: Mapping[str, str] = {}, **kwargs, ) -> AsyncStream[PromptCompletionChunk]: @@ -591,13 +592,13 @@ async def create( self, *, prompt_id: str, - variables: Optional[Mapping[str, Any]] = None, - config: Optional[Union[Mapping, str]] = None, + variables: Union[Mapping[str, Any], NotGiven] = NOT_GIVEN, + config: Union[Mapping, str, NotGiven] = NOT_GIVEN, stream: Literal[False] = False, - temperature: Optional[float] = None, - max_tokens: Optional[int] = None, - top_k: Optional[int] = None, - top_p: Optional[float] = None, + temperature: Union[float, NotGiven] = NOT_GIVEN, + max_tokens: Union[int, NotGiven] = NOT_GIVEN, + top_k: Union[int, NotGiven] = NOT_GIVEN, + top_p: Union[float, NotGiven] = NOT_GIVEN, extra_headers: Mapping[str, str] = {}, **kwargs, ) -> PromptCompletion: @@ -608,13 +609,13 @@ async def create( self, *, prompt_id: str, - variables: Optional[Mapping[str, Any]] = None, - config: Optional[Union[Mapping, str]] = None, + variables: Union[Mapping[str, Any], NotGiven] = NOT_GIVEN, + config: Union[Mapping, str, NotGiven] = NOT_GIVEN, stream: bool = False, - temperature: Optional[float] = None, - max_tokens: Optional[int] = None, - top_k: Optional[int] = None, - top_p: Optional[float] = None, + temperature: Union[float, NotGiven] = NOT_GIVEN, + max_tokens: Union[int, NotGiven] = NOT_GIVEN, + top_k: Union[int, NotGiven] = NOT_GIVEN, + top_p: Union[float, NotGiven] = NOT_GIVEN, extra_headers: Mapping[str, str] = {}, **kwargs, ) -> Union[PromptCompletion, AsyncStream[PromptCompletionChunk]]: @@ -624,18 +625,18 @@ async def create( self, *, prompt_id: str, - variables: Optional[Mapping[str, Any]] = None, - config: Optional[Union[Mapping, str]] = None, + variables: Union[Mapping[str, Any], NotGiven] = NOT_GIVEN, + config: Union[Mapping, str, NotGiven] = NOT_GIVEN, stream: bool = False, - temperature: Optional[float] = None, - max_tokens: Optional[int] = None, - top_k: Optional[int] = None, - top_p: Optional[float] = None, + temperature: Union[float, NotGiven] = NOT_GIVEN, + max_tokens: Union[int, NotGiven] = NOT_GIVEN, + top_k: Union[int, NotGiven] = NOT_GIVEN, + top_p: Union[float, NotGiven] = NOT_GIVEN, extra_headers: Mapping[str, str] = {}, **kwargs, ) -> Union[PromptCompletion, AsyncStream[PromptCompletionChunk]]: """Prompt completions Method""" - if config is None: + if config is NOT_GIVEN: config = retrieve_config() body = { "variables": variables, @@ -696,7 +697,7 @@ def update( prompt_slug: str, version_id: str, *, - label_id: Optional[str] = None, + label_id: Union[str, NotGiven] = NOT_GIVEN, ) -> Any: body = { "label_id": label_id, @@ -750,7 +751,7 @@ async def update( prompt_slug: str, version_id: str, *, - label_id: Optional[str] = None, + label_id: Union[str, NotGiven] = NOT_GIVEN, ) -> Any: body = { "label_id": label_id, @@ -776,8 +777,8 @@ def create( *, name: str, string: str, - workspace_id: Optional[str] = None, - version_description: Optional[str] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + version_description: Union[str, NotGiven] = NOT_GIVEN, ) -> Any: body = { "name": name, @@ -798,12 +799,12 @@ def create( def list( self, *, - collection_id: Optional[str] = None, + collection_id: Union[str, NotGiven] = NOT_GIVEN, ) -> Any: query = { "collection_id": collection_id, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return self._get( f"{PortkeyApiPaths.PROMPTS_PARTIALS_API}?{query_string}", @@ -833,10 +834,10 @@ def update( self, partial_slug: str, *, - name: Optional[str] = None, - string: Optional[str] = None, - description: Optional[str] = None, - status: Optional[str] = None, + name: Union[str, NotGiven] = NOT_GIVEN, + string: Union[str, NotGiven] = NOT_GIVEN, + description: Union[str, NotGiven] = NOT_GIVEN, + status: Union[str, NotGiven] = NOT_GIVEN, ) -> Any: body = { "name": name, @@ -898,8 +899,8 @@ async def create( *, name: str, string: str, - workspace_id: Optional[str] = None, - version_description: Optional[str] = None, + workspace_id: Union[str, NotGiven] = NOT_GIVEN, + version_description: Union[str, NotGiven] = NOT_GIVEN, ) -> Any: body = { "name": name, @@ -920,12 +921,12 @@ async def create( async def list( self, *, - collection_id: Optional[str] = None, + collection_id: Union[str, NotGiven] = NOT_GIVEN, ) -> Any: query = { "collection_id": collection_id, } - filtered_query = {k: v for k, v in query.items() if v is not None} + filtered_query = {k: v for k, v in query.items() if v is not NOT_GIVEN} query_string = urlencode(filtered_query) return await self._get( f"{PortkeyApiPaths.PROMPTS_PARTIALS_API}?{query_string}", @@ -955,10 +956,10 @@ async def update( self, partial_slug: str, *, - name: Optional[str] = None, - string: Optional[str] = None, - description: Optional[str] = None, - status: Optional[str] = None, + name: Union[str, NotGiven] = NOT_GIVEN, + string: Union[str, NotGiven] = NOT_GIVEN, + description: Union[str, NotGiven] = NOT_GIVEN, + status: Union[str, NotGiven] = NOT_GIVEN, ) -> Any: body = { "name": name, From 4fc696f680cd80104707646e21b540bd76bc1e8d Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Mon, 3 Nov 2025 15:09:59 +0530 Subject: [PATCH 13/14] feat: changes in feedback --- portkey_ai/api_resources/apis/feedback.py | 35 ++++++++++++----------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/portkey_ai/api_resources/apis/feedback.py b/portkey_ai/api_resources/apis/feedback.py index 6db0090..8f74ab5 100644 --- a/portkey_ai/api_resources/apis/feedback.py +++ b/portkey_ai/api_resources/apis/feedback.py @@ -1,4 +1,5 @@ -from typing import Optional, Dict, Any, List +from typing import Optional, Dict, Any, List, Union +from portkey_ai._vendor.openai import NOT_GIVEN, NotGiven from portkey_ai.api_resources.apis.api_resource import APIResource, AsyncAPIResource from portkey_ai.api_resources.base_client import APIClient, AsyncAPIClient from portkey_ai.api_resources.streaming import AsyncStream, Stream @@ -13,10 +14,10 @@ def __init__(self, client: APIClient) -> None: def create( self, *, - trace_id: Optional[str] = None, - value: Optional[int] = None, - weight: Optional[float] = None, - metadata: Optional[Dict[str, Any]] = None, + trace_id: Union[str, NotGiven] = NOT_GIVEN, + value: Union[int, NotGiven] = NOT_GIVEN, + weight: Union[float, NotGiven] = NOT_GIVEN, + metadata: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, ) -> FeedbackResponse: body = dict(trace_id=trace_id, value=value, weight=weight, metadata=metadata) return self._post( @@ -44,10 +45,10 @@ def bulk_create(self, *, feedbacks: List[Dict[str, Any]]) -> FeedbackResponse: def update( self, *, - feedback_id: Optional[str] = None, - value: Optional[int] = None, - weight: Optional[float] = None, - metadata: Optional[Dict[str, Any]] = None, + feedback_id: Union[str, NotGiven] = NOT_GIVEN, + value: Union[int, NotGiven] = NOT_GIVEN, + weight: Union[float, NotGiven] = NOT_GIVEN, + metadata: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, ) -> FeedbackResponse: body = dict(value=value, weight=weight, metadata=metadata) @@ -69,10 +70,10 @@ def __init__(self, client: AsyncAPIClient) -> None: async def create( self, *, - trace_id: Optional[str] = None, - value: Optional[int] = None, - weight: Optional[float] = None, - metadata: Optional[Dict[str, Any]] = None, + trace_id: Union[str, NotGiven] = NOT_GIVEN, + value: Union[int, NotGiven] = NOT_GIVEN, + weight: Union[float, NotGiven] = NOT_GIVEN, + metadata: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, ) -> FeedbackResponse: body = dict(trace_id=trace_id, value=value, weight=weight, metadata=metadata) return await self._post( @@ -100,10 +101,10 @@ async def bulk_create(self, *, feedbacks: List[Dict[str, Any]]) -> FeedbackRespo async def update( self, *, - feedback_id: Optional[str] = None, - value: Optional[int] = None, - weight: Optional[float] = None, - metadata: Optional[Dict[str, Any]] = None, + feedback_id: Union[str, NotGiven] = NOT_GIVEN, + value: Union[int, NotGiven] = NOT_GIVEN, + weight: Union[float, NotGiven] = NOT_GIVEN, + metadata: Union[Dict[str, Any], NotGiven] = NOT_GIVEN, ) -> FeedbackResponse: body = dict(value=value, weight=weight, metadata=metadata) return await self._put( From dc1a97db546ab29c710670632dfb256d6061ff4f Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Mon, 3 Nov 2025 15:13:05 +0530 Subject: [PATCH 14/14] feat: changes in feedback --- portkey_ai/api_resources/apis/feedback.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/portkey_ai/api_resources/apis/feedback.py b/portkey_ai/api_resources/apis/feedback.py index 8f74ab5..114b9b2 100644 --- a/portkey_ai/api_resources/apis/feedback.py +++ b/portkey_ai/api_resources/apis/feedback.py @@ -1,4 +1,4 @@ -from typing import Optional, Dict, Any, List, Union +from typing import Dict, Any, List, Union from portkey_ai._vendor.openai import NOT_GIVEN, NotGiven from portkey_ai.api_resources.apis.api_resource import APIResource, AsyncAPIResource from portkey_ai.api_resources.base_client import APIClient, AsyncAPIClient