Skip to content

Commit

Permalink
feat: accepting variables in the generations API (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
noble-varghese authored Sep 19, 2023
1 parent 7890030 commit 30baeb4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions portkey/api_resources/apis.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional, Union, overload, Literal, List
from typing import Optional, Union, overload, Literal, List, Mapping, Any
from portkey.api_resources.base_client import APIClient
from .utils import (
Modes,
Expand Down Expand Up @@ -251,14 +251,19 @@ def create(
class Generations(APIResource):
@classmethod
def create(
cls, *, prompt_id: str, config: Optional[Config] = None, **kwargs
cls,
*,
prompt_id: str,
config: Optional[Config] = None,
variables: Optional[Mapping[str, Any]] = None,
) -> Union[GenericResponse, Stream[GenericResponse]]:
if config is None:
config = retrieve_config()
_client = APIClient(api_key=config.api_key, base_url=config.base_url)
body = {"variables": variables}
return cls(_client)._post(
f"/v1/prompts/{prompt_id}/generate",
body=config.llms,
body=body,
mode=None,
params=None,
cast_to=GenericResponse,
Expand Down

0 comments on commit 30baeb4

Please sign in to comment.