Skip to content

Commit

Permalink
fix: prompt.render.create to prompt.render
Browse files Browse the repository at this point in the history
  • Loading branch information
csgulati09 committed Mar 22, 2024
1 parent d1bbd74 commit 8ce351e
Showing 1 changed file with 16 additions and 126 deletions.
142 changes: 16 additions & 126 deletions portkey_ai/api_resources/apis/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,62 +79,12 @@ async def create(

class Prompts(APIResource):
completions: Completions
render: Render

def __init__(self, client: APIClient) -> None:
super().__init__(client)
self.completions = Completions(client)
self.render = Render(client)


class AsyncPrompts(AsyncAPIResource):
completions: AsyncCompletions
render: AsyncRender

def __init__(self, client: AsyncAPIClient) -> None:
super().__init__(client)
self.completions = AsyncCompletions(client)
self.render = AsyncRender(client)


class Completions(APIResource):
def __init__(self, client: APIClient) -> None:
super().__init__(client)

@overload
def create(
self,
*,
prompt_id: str,
variables: Optional[Mapping[str, Any]] = None,
config: Optional[Union[Mapping, str]] = None,
stream: Literal[True],
temperature: Optional[float] = None,
max_tokens: Optional[int] = None,
top_k: Optional[int] = None,
top_p: Optional[float] = None,
**kwargs,
) -> Stream[GenericResponse]:
...

@overload
def create(
self,
*,
prompt_id: str,
variables: Optional[Mapping[str, Any]] = None,
config: Optional[Union[Mapping, str]] = None,
stream: Literal[False] = False,
temperature: Optional[float] = None,
max_tokens: Optional[int] = None,
top_k: Optional[int] = None,
top_p: Optional[float] = None,
**kwargs,
) -> GenericResponse:
...

@overload
def create(
def render(
self,
*,
prompt_id: str,
Expand All @@ -147,22 +97,7 @@ def create(
top_p: Optional[float] = None,
**kwargs,
) -> Union[GenericResponse, Stream[GenericResponse]]:
...

def create(
self,
*,
prompt_id: str,
variables: Optional[Mapping[str, Any]] = None,
config: Optional[Union[Mapping, str]] = None,
stream: bool = False,
temperature: Optional[float] = None,
max_tokens: Optional[int] = None,
top_k: Optional[int] = None,
top_p: Optional[float] = None,
**kwargs,
) -> Union[GenericResponse, Stream[GenericResponse]]:
"""Prompt completions Method"""
"""Prompt render Method"""
if config is None:
config = retrieve_config()
body = {
Expand All @@ -175,7 +110,7 @@ def create(
**kwargs,
}
return self._post(
f"/prompts/{prompt_id}/completions",
f"/prompts/{prompt_id}/render",
body=body,
params=None,
cast_to=GenericResponse,
Expand All @@ -185,59 +120,14 @@ def create(
)


class AsyncCompletions(AsyncAPIResource):
class AsyncPrompts(AsyncAPIResource):
completions: AsyncCompletions

def __init__(self, client: AsyncAPIClient) -> None:
super().__init__(client)
self.completions = AsyncCompletions(client)

@overload
async def create(
self,
*,
prompt_id: str,
variables: Optional[Mapping[str, Any]] = None,
config: Optional[Union[Mapping, str]] = None,
stream: Literal[True],
temperature: Optional[float] = None,
max_tokens: Optional[int] = None,
top_k: Optional[int] = None,
top_p: Optional[float] = None,
**kwargs,
) -> AsyncStream[GenericResponse]:
...

@overload
async def create(
self,
*,
prompt_id: str,
variables: Optional[Mapping[str, Any]] = None,
config: Optional[Union[Mapping, str]] = None,
stream: Literal[False] = False,
temperature: Optional[float] = None,
max_tokens: Optional[int] = None,
top_k: Optional[int] = None,
top_p: Optional[float] = None,
**kwargs,
) -> GenericResponse:
...

@overload
async def create(
self,
*,
prompt_id: str,
variables: Optional[Mapping[str, Any]] = None,
config: Optional[Union[Mapping, str]] = None,
stream: bool = False,
temperature: Optional[float] = None,
max_tokens: Optional[int] = None,
top_k: Optional[int] = None,
top_p: Optional[float] = None,
**kwargs,
) -> Union[GenericResponse, AsyncStream[GenericResponse]]:
...

async def create(
async def render(
self,
*,
prompt_id: str,
Expand All @@ -250,7 +140,7 @@ async def create(
top_p: Optional[float] = None,
**kwargs,
) -> Union[GenericResponse, AsyncStream[GenericResponse]]:
"""Prompt completions Method"""
"""Prompt render Method"""
if config is None:
config = retrieve_config()
body = {
Expand All @@ -263,7 +153,7 @@ async def create(
**kwargs,
}
return await self._post(
f"/prompts/{prompt_id}/completions",
f"/prompts/{prompt_id}/render",
body=body,
params=None,
cast_to=GenericResponse,
Expand All @@ -273,7 +163,7 @@ async def create(
)


class Render(APIResource):
class Completions(APIResource):
def __init__(self, client: APIClient) -> None:
super().__init__(client)

Expand Down Expand Up @@ -338,7 +228,7 @@ def create(
top_p: Optional[float] = None,
**kwargs,
) -> Union[GenericResponse, Stream[GenericResponse]]:
"""Prompt render Method"""
"""Prompt completions Method"""
if config is None:
config = retrieve_config()
body = {
Expand All @@ -351,7 +241,7 @@ def create(
**kwargs,
}
return self._post(
f"/prompts/{prompt_id}/render",
f"/prompts/{prompt_id}/completions",
body=body,
params=None,
cast_to=GenericResponse,
Expand All @@ -361,7 +251,7 @@ def create(
)


class AsyncRender(AsyncAPIResource):
class AsyncCompletions(AsyncAPIResource):
def __init__(self, client: AsyncAPIClient) -> None:
super().__init__(client)

Expand Down Expand Up @@ -426,7 +316,7 @@ async def create(
top_p: Optional[float] = None,
**kwargs,
) -> Union[GenericResponse, AsyncStream[GenericResponse]]:
"""Prompt render Method"""
"""Prompt completions Method"""
if config is None:
config = retrieve_config()
body = {
Expand All @@ -439,7 +329,7 @@ async def create(
**kwargs,
}
return await self._post(
f"/prompts/{prompt_id}/render",
f"/prompts/{prompt_id}/completions",
body=body,
params=None,
cast_to=GenericResponse,
Expand Down

0 comments on commit 8ce351e

Please sign in to comment.