Skip to content

Commit

Permalink
use poetry to reformat file
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheepsta300 committed Aug 20, 2024
1 parent db238a7 commit 4d1ccd7
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

logger = logging.getLogger(__name__)


class AzureOpenAIWhisperParser(BaseBlobParser):
"""Transcribe and parse audio files.
Expand Down Expand Up @@ -82,9 +83,11 @@ def lazy_parse(self, blob: Blob) -> Iterator[Document]:
if is_openai_v1():
# api_key optional, defaults to `os.environ['AZURE_OPENAI_API_KEY']`
# same for azure_endpoint and api_version
client = openai.AzureOpenAI(api_key=self.api_key,
azure_endpoint=self.azure_endpoint,
api_version=self.api_version)
client = openai.AzureOpenAI(
api_key=self.api_key,
azure_endpoint=self.azure_endpoint,
api_version=self.api_version,
)
else:
# Set the API key if provided
if self.api_key:
Expand Down Expand Up @@ -120,15 +123,14 @@ def lazy_parse(self, blob: Blob) -> Iterator[Document]:
try:
if is_openai_v1():
transcript = client.audio.transcriptions.create(
model=self.deployment_id,
file=file_obj,
**self._create_params
)
model=self.deployment_id,
file=file_obj,
**self._create_params,
)
else:
transcript = openai.Audio.transcribe(
self.deployment_id,
file_obj
)
self.deployment_id, file_obj
)
break
except Exception as e:
attempts += 1
Expand All @@ -143,6 +145,7 @@ def lazy_parse(self, blob: Blob) -> Iterator[Document]:
metadata={"source": blob.source, "chunk": split_number},
)


class OpenAIWhisperParser(BaseBlobParser):
"""Transcribe and parse audio files.
Expand Down

0 comments on commit 4d1ccd7

Please sign in to comment.