Skip to content

Commit 204e313

Browse files
committed
feat: integration models support added
1 parent 2b3f9ca commit 204e313

4 files changed

Lines changed: 100 additions & 0 deletions

File tree

portkey_ai/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@
127127
AsyncIntegrations,
128128
IntegrationsWorkspaces,
129129
AsyncIntegrationsWorkspaces,
130+
IntegrationsModels,
131+
AsyncIntegrationsModels,
130132
)
131133

132134
from portkey_ai.version import VERSION
@@ -273,4 +275,6 @@
273275
"AsyncIntegrations",
274276
"IntegrationsWorkspaces",
275277
"AsyncIntegrationsWorkspaces",
278+
"IntegrationsModels",
279+
"AsyncIntegrationsModels",
276280
]

portkey_ai/api_resources/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@
115115
AsyncIntegrations,
116116
IntegrationsWorkspaces,
117117
AsyncIntegrationsWorkspaces,
118+
IntegrationsModels,
119+
AsyncIntegrationsModels,
118120
)
119121
from .utils import (
120122
Modes,
@@ -265,4 +267,6 @@
265267
"AsyncIntegrations",
266268
"IntegrationsWorkspaces",
267269
"AsyncIntegrationsWorkspaces",
270+
"IntegrationsModels",
271+
"AsyncIntegrationsModels",
268272
]

portkey_ai/api_resources/apis/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@
144144
AsyncIntegrations,
145145
IntegrationsWorkspaces,
146146
AsyncIntegrationsWorkspaces,
147+
IntegrationsModels,
148+
AsyncIntegrationsModels,
147149
)
148150

149151
sys.modules["openai"] = vendored_openai # For pydantic v1 and v2 compatibility
@@ -274,4 +276,6 @@
274276
"AsyncIntegrations",
275277
"IntegrationsWorkspaces",
276278
"AsyncIntegrationsWorkspaces",
279+
"IntegrationsModels",
280+
"AsyncIntegrationsModels",
277281
]

portkey_ai/api_resources/apis/integrations.py

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class Integrations(APIResource):
1010
def __init__(self, client: APIClient) -> None:
1111
super().__init__(client)
1212
self.workspaces = IntegrationsWorkspaces(client)
13+
self.models = IntegrationsModels(client)
1314

1415
def create(
1516
self,
@@ -174,10 +175,54 @@ def update(
174175
)
175176

176177

178+
class IntegrationsModels(APIResource):
179+
def __init__(self, client: APIClient) -> None:
180+
super().__init__(client)
181+
182+
def list(
183+
self,
184+
*,
185+
provider_integration_id: Optional[str] = None,
186+
) -> GenericResponse:
187+
return self._get(
188+
f"{PortkeyApiPaths.INTEGRATIONS_API}/{provider_integration_id}/models",
189+
params=None,
190+
body=None,
191+
cast_to=GenericResponse,
192+
stream=False,
193+
stream_cls=None,
194+
headers={},
195+
)
196+
197+
def update(
198+
self,
199+
*,
200+
provider_integration_id: Optional[str] = None,
201+
allow_all_models: Optional[bool] = None,
202+
models: Optional[List[Dict[str, Any]]] = None,
203+
**kwargs: Any,
204+
) -> GenericResponse:
205+
body = {
206+
"allow_all_models": allow_all_models,
207+
"models": models,
208+
**kwargs,
209+
}
210+
return self._put(
211+
f"{PortkeyApiPaths.INTEGRATIONS_API}/{provider_integration_id}/models",
212+
body=body,
213+
params=None,
214+
cast_to=GenericResponse,
215+
stream=False,
216+
stream_cls=None,
217+
headers={},
218+
)
219+
220+
177221
class AsyncIntegrations(AsyncAPIResource):
178222
def __init__(self, client: AsyncAPIClient) -> None:
179223
super().__init__(client)
180224
self.workspaces = AsyncIntegrationsWorkspaces(client)
225+
self.models = AsyncIntegrationsModels(client)
181226

182227
async def create(
183228
self,
@@ -340,3 +385,46 @@ async def update(
340385
stream_cls=None,
341386
headers={},
342387
)
388+
389+
390+
class AsyncIntegrationsModels(AsyncAPIResource):
391+
def __init__(self, client: AsyncAPIClient) -> None:
392+
super().__init__(client)
393+
394+
async def list(
395+
self,
396+
*,
397+
provider_integration_id: Optional[str] = None,
398+
) -> GenericResponse:
399+
return await self._get(
400+
f"{PortkeyApiPaths.INTEGRATIONS_API}/{provider_integration_id}/models",
401+
params=None,
402+
body=None,
403+
cast_to=GenericResponse,
404+
stream=False,
405+
stream_cls=None,
406+
headers={},
407+
)
408+
409+
async def update(
410+
self,
411+
*,
412+
provider_integration_id: Optional[str] = None,
413+
allow_all_models: Optional[bool] = None,
414+
models: Optional[List[Dict[str, Any]]] = None,
415+
**kwargs: Any,
416+
) -> GenericResponse:
417+
body = {
418+
"allow_all_models": allow_all_models,
419+
"models": models,
420+
**kwargs,
421+
}
422+
return await self._put(
423+
f"{PortkeyApiPaths.INTEGRATIONS_API}/{provider_integration_id}/models",
424+
body=body,
425+
params=None,
426+
cast_to=GenericResponse,
427+
stream=False,
428+
stream_cls=None,
429+
headers={},
430+
)

0 commit comments

Comments
 (0)