Skip to content

Commit

Permalink
[audio] Use supplied api key (openai#170) (openai#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpokrass authored and davedittrich committed Nov 14, 2023
1 parent 7079f1f commit ff1b2c1
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 9 deletions.
80 changes: 72 additions & 8 deletions openai/api_resources/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,15 @@ def transcribe(
organization=None,
**params,
):
requestor, files, data = cls._prepare_request(file, file.name, model, **params)
requestor, files, data = cls._prepare_request(
file=file,
filename=file.name,
model=model,
api_key=api_key,
api_base=api_base,
api_type=api_type,
**params,
)
url = cls._get_url("transcriptions")
response, _, api_key = requestor.request("post", url, files=files, params=data)
return util.convert_to_openai_object(
Expand All @@ -71,7 +79,15 @@ def translate(
organization=None,
**params,
):
requestor, files, data = cls._prepare_request(file, file.name, model, **params)
requestor, files, data = cls._prepare_request(
file=file,
filename=file.name,
model=model,
api_key=api_key,
api_base=api_base,
api_type=api_type,
**params,
)
url = cls._get_url("translations")
response, _, api_key = requestor.request("post", url, files=files, params=data)
return util.convert_to_openai_object(
Expand All @@ -91,7 +107,15 @@ def transcribe_raw(
organization=None,
**params,
):
requestor, files, data = cls._prepare_request(file, filename, model, **params)
requestor, files, data = cls._prepare_request(
file=file,
filename=filename,
model=model,
api_key=api_key,
api_base=api_base,
api_type=api_type,
**params,
)
url = cls._get_url("transcriptions")
response, _, api_key = requestor.request("post", url, files=files, params=data)
return util.convert_to_openai_object(
Expand All @@ -111,7 +135,15 @@ def translate_raw(
organization=None,
**params,
):
requestor, files, data = cls._prepare_request(file, filename, model, **params)
requestor, files, data = cls._prepare_request(
file=file,
filename=filename,
model=model,
api_key=api_key,
api_base=api_base,
api_type=api_type,
**params,
)
url = cls._get_url("translations")
response, _, api_key = requestor.request("post", url, files=files, params=data)
return util.convert_to_openai_object(
Expand All @@ -130,7 +162,15 @@ async def atranscribe(
organization=None,
**params,
):
requestor, files, data = cls._prepare_request(file, file.name, model, **params)
requestor, files, data = cls._prepare_request(
file=file,
filename=file.name,
model=model,
api_key=api_key,
api_base=api_base,
api_type=api_type,
**params,
)
url = cls._get_url("transcriptions")
response, _, api_key = await requestor.arequest(
"post", url, files=files, params=data
Expand All @@ -151,7 +191,15 @@ async def atranslate(
organization=None,
**params,
):
requestor, files, data = cls._prepare_request(file, file.name, model, **params)
requestor, files, data = cls._prepare_request(
file=file,
filename=file.name,
model=model,
api_key=api_key,
api_base=api_base,
api_type=api_type,
**params,
)
url = cls._get_url("translations")
response, _, api_key = await requestor.arequest(
"post", url, files=files, params=data
Expand All @@ -173,7 +221,15 @@ async def atranscribe_raw(
organization=None,
**params,
):
requestor, files, data = cls._prepare_request(file, filename, model, **params)
requestor, files, data = cls._prepare_request(
file=file,
filename=filename,
model=model,
api_key=api_key,
api_base=api_base,
api_type=api_type,
**params,
)
url = cls._get_url("transcriptions")
response, _, api_key = await requestor.arequest(
"post", url, files=files, params=data
Expand All @@ -195,7 +251,15 @@ async def atranslate_raw(
organization=None,
**params,
):
requestor, files, data = cls._prepare_request(file, filename, model, **params)
requestor, files, data = cls._prepare_request(
file=file,
filename=filename,
model=model,
api_key=api_key,
api_base=api_base,
api_type=api_type,
**params,
)
url = cls._get_url("translations")
response, _, api_key = await requestor.arequest(
"post", url, files=files, params=data
Expand Down
2 changes: 1 addition & 1 deletion openai/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "0.27.2"
VERSION = "0.27.3"

0 comments on commit ff1b2c1

Please sign in to comment.