Skip to content

Commit

Permalink
Merge pull request #133 from Portkey-AI/feat/openai1.26.0
Browse files Browse the repository at this point in the history
Feat/openai1.26.0
  • Loading branch information
VisargD committed May 31, 2024
2 parents 031235d + fa196ea commit 8b1cbd0
Show file tree
Hide file tree
Showing 38 changed files with 4,138 additions and 224 deletions.
56 changes: 48 additions & 8 deletions portkey_ai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,34 @@
AsyncMainFiles,
Models,
AsyncModels,
ThreadFiles,
AsyncThreadFiles,
AssistantFiles,
AsyncAssistantFiles,
Runs,
AsyncRuns,
Steps,
AsyncSteps,
Moderations,
AsyncModerations,
Audio,
Transcriptions,
Translations,
Speech,
AsyncAudio,
AsyncTranscriptions,
AsyncTranslations,
AsyncSpeech,
Batches,
AsyncBatches,
FineTuning,
Jobs,
Checkpoints,
AsyncFineTuning,
AsyncJobs,
AsyncCheckpoints,
VectorStores,
VectorFiles,
VectorFileBatches,
AsyncVectorStores,
AsyncVectorFiles,
AsyncVectorFileBatches,
)

from portkey_ai.version import VERSION
Expand Down Expand Up @@ -95,12 +115,32 @@
"AsyncMainFiles",
"Models",
"AsyncModels",
"ThreadFiles",
"AsyncThreadFiles",
"AssistantFiles",
"AsyncAssistantFiles",
"Runs",
"AsyncRuns",
"Steps",
"AsyncSteps",
"Moderations",
"AsyncModerations",
"Audio",
"Transcriptions",
"Translations",
"Speech",
"AsyncAudio",
"AsyncTranscriptions",
"AsyncTranslations",
"AsyncSpeech",
"Batches",
"AsyncBatches",
"FineTuning",
"Jobs",
"Checkpoints",
"AsyncFineTuning",
"AsyncJobs",
"AsyncCheckpoints",
"VectorStores",
"VectorFiles",
"VectorFileBatches",
"AsyncVectorStores",
"AsyncVectorFiles",
"AsyncVectorFileBatches",
]
56 changes: 48 additions & 8 deletions portkey_ai/api_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,34 @@
AsyncMainFiles,
Models,
AsyncModels,
ThreadFiles,
AsyncThreadFiles,
AssistantFiles,
AsyncAssistantFiles,
Runs,
AsyncRuns,
Steps,
AsyncSteps,
Moderations,
AsyncModerations,
Audio,
Transcriptions,
Translations,
Speech,
AsyncAudio,
AsyncTranscriptions,
AsyncTranslations,
AsyncSpeech,
Batches,
AsyncBatches,
FineTuning,
Jobs,
Checkpoints,
AsyncFineTuning,
AsyncJobs,
AsyncCheckpoints,
VectorStores,
VectorFiles,
VectorFileBatches,
AsyncVectorStores,
AsyncVectorFiles,
AsyncVectorFileBatches,
)
from .utils import (
Modes,
Expand Down Expand Up @@ -89,12 +109,32 @@
"AsyncMainFiles",
"Models",
"AsyncModels",
"ThreadFiles",
"AsyncThreadFiles",
"AssistantFiles",
"AsyncAssistantFiles",
"Runs",
"AsyncRuns",
"Steps",
"AsyncSteps",
"Moderations",
"AsyncModerations",
"Audio",
"Transcriptions",
"Translations",
"Speech",
"AsyncAudio",
"AsyncTranscriptions",
"AsyncTranslations",
"AsyncSpeech",
"Batches",
"AsyncBatches",
"FineTuning",
"Jobs",
"Checkpoints",
"AsyncFineTuning",
"AsyncJobs",
"AsyncCheckpoints",
"VectorStores",
"VectorFiles",
"VectorFileBatches",
"AsyncVectorStores",
"AsyncVectorFiles",
"AsyncVectorFileBatches",
]
61 changes: 54 additions & 7 deletions portkey_ai/api_resources/apis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,48 @@
from .post import Post, AsyncPost
from .embeddings import Embeddings, AsyncEmbeddings
from .images import Images, AsyncImages
from .assistants import Assistants, AssistantFiles, AsyncAssistants, AsyncAssistantFiles
from .assistants import Assistants, AsyncAssistants
from .threads import (
Threads,
Messages,
ThreadFiles,
Runs,
Steps,
AsyncThreads,
AsyncMessages,
AsyncThreadFiles,
AsyncRuns,
AsyncSteps,
)
from .main_files import MainFiles, AsyncMainFiles
from .models import Models, AsyncModels
from .moderations import Moderations, AsyncModerations
from .audio import (
Audio,
Transcriptions,
Translations,
Speech,
AsyncAudio,
AsyncTranscriptions,
AsyncTranslations,
AsyncSpeech,
)
from .batches import Batches, AsyncBatches
from .fine_tuning import (
FineTuning,
Jobs,
Checkpoints,
AsyncFineTuning,
AsyncJobs,
AsyncCheckpoints,
)
from .vector_stores import (
VectorStores,
VectorFiles,
VectorFileBatches,
AsyncVectorStores,
AsyncVectorFiles,
AsyncVectorFileBatches,
)


__all__ = [
"Completion",
Expand All @@ -46,10 +73,6 @@
"AsyncMainFiles",
"Models",
"AsyncModels",
"AssistantFiles",
"ThreadFiles",
"AsyncAssistantFiles",
"AsyncThreadFiles",
"Threads",
"AsyncThreads",
"Messages",
Expand All @@ -58,4 +81,28 @@
"AsyncRuns",
"Steps",
"AsyncSteps",
"Moderations",
"AsyncModerations",
"Audio",
"Transcriptions",
"Translations",
"Speech",
"AsyncAudio",
"AsyncTranscriptions",
"AsyncTranslations",
"AsyncSpeech",
"Batches",
"AsyncBatches",
"FineTuning",
"Jobs",
"Checkpoints",
"AsyncFineTuning",
"AsyncJobs",
"AsyncCheckpoints",
"VectorStores",
"VectorFiles",
"VectorFileBatches",
"AsyncVectorStores",
"AsyncVectorFiles",
"AsyncVectorFileBatches",
]
97 changes: 0 additions & 97 deletions portkey_ai/api_resources/apis/assistants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@
Assistant,
AssistantList,
AssistantDeleted,
AssistantFile,
AssistantFileList,
AssistantFileDeleted,
)


class Assistants(APIResource):
def __init__(self, client: Portkey) -> None:
super().__init__(client)
self.openai_client = client.openai_client
self.files = AssistantFiles(client)

def create(self, **kwargs) -> Assistant:
response = self.openai_client.with_raw_response.beta.assistants.create(**kwargs)
Expand Down Expand Up @@ -59,53 +55,10 @@ def delete(self, assistant_id, **kwargs) -> AssistantDeleted:
return data


class AssistantFiles(APIResource):
def __init__(self, client: Portkey) -> None:
super().__init__(client)
self.openai_client = client.openai_client

def create(self, assistant_id, file_id, **kwargs) -> AssistantFile:
response = self.openai_client.with_raw_response.beta.assistants.files.create(
assistant_id=assistant_id, file_id=file_id, **kwargs
)
data = AssistantFile(**json.loads(response.text))
data._headers = response.headers

return data

def list(self, assistant_id, **kwargs) -> AssistantFileList:
response = self.openai_client.with_raw_response.beta.assistants.files.list(
assistant_id=assistant_id, **kwargs
)
data = AssistantFileList(**json.loads(response.text))
data._headers = response.headers

return data

def retrieve(self, assistant_id, file_id, **kwargs) -> AssistantFile:
response = self.openai_client.with_raw_response.beta.assistants.files.retrieve(
assistant_id=assistant_id, file_id=file_id, **kwargs
)
data = AssistantFile(**json.loads(response.text))
data._headers = response.headers

return data

def delete(self, assistant_id, file_id, **kwargs) -> AssistantFileDeleted:
response = self.openai_client.with_raw_response.beta.assistants.files.delete(
assistant_id=assistant_id, file_id=file_id, **kwargs
)
data = AssistantFileDeleted(**json.loads(response.text))
data._headers = response.headers

return data


class AsyncAssistants(AsyncAPIResource):
def __init__(self, client: AsyncPortkey) -> None:
super().__init__(client)
self.openai_client = client.openai_client
self.files = AsyncAssistantFiles(client)

async def create(self, **kwargs) -> Assistant:
response = await self.openai_client.with_raw_response.beta.assistants.create(
Expand Down Expand Up @@ -151,53 +104,3 @@ async def delete(self, assistant_id, **kwargs) -> AssistantDeleted:
data._headers = response.headers

return data


class AsyncAssistantFiles(AsyncAPIResource):
def __init__(self, client: AsyncPortkey) -> None:
super().__init__(client)
self.openai_client = client.openai_client

async def create(self, assistant_id, file_id, **kwargs) -> AssistantFile:
response = (
await self.openai_client.with_raw_response.beta.assistants.files.create(
assistant_id=assistant_id, file_id=file_id, **kwargs
)
)
data = AssistantFile(**json.loads(response.text))
data._headers = response.headers

return data

async def list(self, assistant_id, **kwargs) -> AssistantFileList:
response = (
await self.openai_client.with_raw_response.beta.assistants.files.list(
assistant_id=assistant_id, **kwargs
)
)
data = AssistantFileList(**json.loads(response.text))
data._headers = response.headers

return data

async def retrieve(self, assistant_id, file_id, **kwargs) -> AssistantFile:
response = (
await self.openai_client.with_raw_response.beta.assistants.files.retrieve(
assistant_id=assistant_id, file_id=file_id, **kwargs
)
)
data = AssistantFile(**json.loads(response.text))
data._headers = response.headers

return data

async def delete(self, assistant_id, file_id, **kwargs) -> AssistantFileDeleted:
response = (
await self.openai_client.with_raw_response.beta.assistants.files.delete(
assistant_id=assistant_id, file_id=file_id, **kwargs
)
)
data = AssistantFileDeleted(**json.loads(response.text))
data._headers = response.headers

return data

0 comments on commit 8b1cbd0

Please sign in to comment.