cleaned version
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import httpx
|
||||
|
||||
from ..config import OPENAI_BASE_URL, UPSTREAM_TIMEOUT_SECONDS
|
||||
from ..errors import UpstreamError
|
||||
from ..errors import UpstreamError, raise_for_upstream
|
||||
from ..logging_config import get_logger
|
||||
|
||||
log = get_logger("audio-transcription.openai")
|
||||
@@ -33,12 +33,8 @@ async def transcribe(
|
||||
raise UpstreamError(f"OpenAI Whisper request se nezdařil: {exc}") from exc
|
||||
|
||||
if resp.status_code >= 400:
|
||||
snippet = resp.text[:500]
|
||||
log.warning("OpenAI transcription returned %s: %s", resp.status_code, snippet)
|
||||
raise UpstreamError(
|
||||
f"OpenAI Whisper vrátil chybu {resp.status_code}.",
|
||||
detail=snippet,
|
||||
)
|
||||
log.warning("OpenAI transcription returned %s: %s", resp.status_code, resp.text[:500])
|
||||
raise_for_upstream("OpenAI Whisper", resp.status_code, resp.text)
|
||||
|
||||
data = resp.json()
|
||||
return data.get("text", "") or ""
|
||||
@@ -72,12 +68,8 @@ async def merge_transcripts(
|
||||
raise UpstreamError(f"OpenAI chat (merge) request se nezdařil: {exc}") from exc
|
||||
|
||||
if resp.status_code >= 400:
|
||||
snippet = resp.text[:500]
|
||||
log.warning("OpenAI chat returned %s: %s", resp.status_code, snippet)
|
||||
raise UpstreamError(
|
||||
f"OpenAI chat (merge) vrátil chybu {resp.status_code}.",
|
||||
detail=snippet,
|
||||
)
|
||||
log.warning("OpenAI chat returned %s: %s", resp.status_code, resp.text[:500])
|
||||
raise_for_upstream("OpenAI chat (merge)", resp.status_code, resp.text)
|
||||
|
||||
data = resp.json()
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user