forked from phoenix/litellm-mirror
fix(main.py): pass api key and api base to openai.py for audio transcription call
This commit is contained in:
parent
76b5fccdc2
commit
da56201e80
3 changed files with 24 additions and 3 deletions
|
@ -1465,6 +1465,8 @@ Model Info:
|
|||
final_value = float(
|
||||
response_s.total_seconds() / completion_tokens
|
||||
)
|
||||
if isinstance(final_value, timedelta):
|
||||
final_value = final_value.total_seconds()
|
||||
|
||||
await self.async_update_daily_reports(
|
||||
DeploymentMetrics(
|
||||
|
|
|
@ -1090,8 +1090,8 @@ class OpenAIChatCompletion(BaseLLM):
|
|||
model_response: TranscriptionResponse,
|
||||
timeout: float,
|
||||
max_retries: int,
|
||||
api_key: Optional[str] = None,
|
||||
api_base: Optional[str] = None,
|
||||
api_key: Optional[str],
|
||||
api_base: Optional[str],
|
||||
client=None,
|
||||
logging_obj=None,
|
||||
atranscription: bool = False,
|
||||
|
@ -1147,7 +1147,6 @@ class OpenAIChatCompletion(BaseLLM):
|
|||
max_retries=None,
|
||||
logging_obj=None,
|
||||
):
|
||||
response = None
|
||||
try:
|
||||
if client is None:
|
||||
openai_aclient = AsyncOpenAI(
|
||||
|
|
|
@ -4130,6 +4130,24 @@ def transcription(
|
|||
max_retries=max_retries,
|
||||
)
|
||||
elif custom_llm_provider == "openai":
|
||||
api_base = (
|
||||
api_base
|
||||
or litellm.api_base
|
||||
or get_secret("OPENAI_API_BASE")
|
||||
or "https://api.openai.com/v1"
|
||||
) # type: ignore
|
||||
openai.organization = (
|
||||
litellm.organization
|
||||
or get_secret("OPENAI_ORGANIZATION")
|
||||
or None # default - https://github.com/openai/openai-python/blob/284c1799070c723c6a553337134148a7ab088dd8/openai/util.py#L105
|
||||
)
|
||||
# set API KEY
|
||||
api_key = (
|
||||
api_key
|
||||
or litellm.api_key
|
||||
or litellm.openai_key
|
||||
or get_secret("OPENAI_API_KEY")
|
||||
) # type: ignore
|
||||
response = openai_chat_completions.audio_transcriptions(
|
||||
model=model,
|
||||
audio_file=file,
|
||||
|
@ -4139,6 +4157,8 @@ def transcription(
|
|||
timeout=timeout,
|
||||
logging_obj=litellm_logging_obj,
|
||||
max_retries=max_retries,
|
||||
api_base=api_base,
|
||||
api_key=api_key,
|
||||
)
|
||||
return response
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue