forked from phoenix/litellm-mirror
fix(azure.py): add pre call logging for transcription calls
This commit is contained in:
parent
9274245a0b
commit
fac01f8481
3 changed files with 33 additions and 0 deletions
|
@ -15,6 +15,7 @@ import litellm, json
|
|||
import httpx
|
||||
from .custom_httpx.azure_dall_e_2 import CustomHTTPTransport, AsyncCustomHTTPTransport
|
||||
from openai import AzureOpenAI, AsyncAzureOpenAI
|
||||
import uuid
|
||||
|
||||
|
||||
class AzureOpenAIError(Exception):
|
||||
|
@ -809,6 +810,19 @@ class AzureChatCompletion(BaseLLM):
|
|||
azure_client = AzureOpenAI(http_client=litellm.client_session, **azure_client_params) # type: ignore
|
||||
else:
|
||||
azure_client = client
|
||||
|
||||
## LOGGING
|
||||
logging_obj.pre_call(
|
||||
input=f"audio_file_{uuid.uuid4()}",
|
||||
api_key=azure_client.api_key,
|
||||
additional_args={
|
||||
"headers": {"Authorization": f"Bearer {azure_client.api_key}"},
|
||||
"api_base": azure_client._base_url._uri_reference,
|
||||
"atranscription": True,
|
||||
"complete_input_dict": data,
|
||||
},
|
||||
)
|
||||
|
||||
response = azure_client.audio.transcriptions.create(
|
||||
**data, timeout=timeout # type: ignore
|
||||
)
|
||||
|
@ -845,6 +859,21 @@ class AzureChatCompletion(BaseLLM):
|
|||
)
|
||||
else:
|
||||
async_azure_client = client
|
||||
|
||||
## LOGGING
|
||||
logging_obj.pre_call(
|
||||
input=f"audio_file_{uuid.uuid4()}",
|
||||
api_key=async_azure_client.api_key,
|
||||
additional_args={
|
||||
"headers": {
|
||||
"Authorization": f"Bearer {async_azure_client.api_key}"
|
||||
},
|
||||
"api_base": async_azure_client._base_url._uri_reference,
|
||||
"atranscription": True,
|
||||
"complete_input_dict": data,
|
||||
},
|
||||
)
|
||||
|
||||
response = await async_azure_client.audio.transcriptions.create(
|
||||
**data, timeout=timeout
|
||||
) # type: ignore
|
||||
|
|
|
@ -981,6 +981,7 @@ class Logging:
|
|||
curl_command = self.model_call_details
|
||||
|
||||
# only print verbose if verbose logger is not set
|
||||
|
||||
if verbose_logger.level == 0:
|
||||
# this means verbose logger was not switched on - user is in litellm.set_verbose=True
|
||||
print_verbose(f"\033[92m{curl_command}\033[0m\n")
|
||||
|
|
|
@ -35,6 +35,7 @@ def test_transcription():
|
|||
|
||||
|
||||
def test_transcription_azure():
|
||||
litellm.set_verbose = True
|
||||
transcript = litellm.transcription(
|
||||
model="azure/azure-whisper",
|
||||
file=audio_file,
|
||||
|
@ -46,6 +47,8 @@ def test_transcription_azure():
|
|||
assert transcript.text is not None
|
||||
assert isinstance(transcript.text, str)
|
||||
|
||||
raise Exception("it worked")
|
||||
|
||||
|
||||
# test_transcription_azure()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue