Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/openai1.26.0 #133

Merged
merged 18 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading
Loading