forked from phoenix/litellm-mirror
fix(main.py): add logging to audio_transcription calls
This commit is contained in:
parent
93166cdabf
commit
d65b7fe01b
5 changed files with 37 additions and 1 deletions
|
@ -4164,6 +4164,7 @@ def transcription(
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
@client
|
||||||
async def aspeech(*args, **kwargs) -> HttpxBinaryResponseContent:
|
async def aspeech(*args, **kwargs) -> HttpxBinaryResponseContent:
|
||||||
"""
|
"""
|
||||||
Calls openai tts endpoints.
|
Calls openai tts endpoints.
|
||||||
|
@ -4204,6 +4205,7 @@ async def aspeech(*args, **kwargs) -> HttpxBinaryResponseContent:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@client
|
||||||
def speech(
|
def speech(
|
||||||
model: str,
|
model: str,
|
||||||
input: str,
|
input: str,
|
||||||
|
|
|
@ -5002,13 +5002,39 @@ async def audio_speech(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
### ALERTING ###
|
||||||
|
data["litellm_status"] = "success" # used for alerting
|
||||||
|
|
||||||
|
### RESPONSE HEADERS ###
|
||||||
|
hidden_params = getattr(response, "_hidden_params", {}) or {}
|
||||||
|
model_id = hidden_params.get("model_id", None) or ""
|
||||||
|
cache_key = hidden_params.get("cache_key", None) or ""
|
||||||
|
api_base = hidden_params.get("api_base", None) or ""
|
||||||
|
|
||||||
# Printing each chunk size
|
# Printing each chunk size
|
||||||
async def generate(_response: HttpxBinaryResponseContent):
|
async def generate(_response: HttpxBinaryResponseContent):
|
||||||
_generator = await _response.aiter_bytes(chunk_size=1024)
|
_generator = await _response.aiter_bytes(chunk_size=1024)
|
||||||
async for chunk in _generator:
|
async for chunk in _generator:
|
||||||
yield chunk
|
yield chunk
|
||||||
|
|
||||||
return StreamingResponse(generate(response), media_type="audio/mpeg")
|
custom_headers = get_custom_headers(
|
||||||
|
user_api_key_dict=user_api_key_dict,
|
||||||
|
model_id=model_id,
|
||||||
|
cache_key=cache_key,
|
||||||
|
api_base=api_base,
|
||||||
|
version=version,
|
||||||
|
model_region=getattr(user_api_key_dict, "allowed_model_region", ""),
|
||||||
|
fastest_response_batch_completion=None,
|
||||||
|
)
|
||||||
|
|
||||||
|
selected_data_generator = select_data_generator(
|
||||||
|
response=response,
|
||||||
|
user_api_key_dict=user_api_key_dict,
|
||||||
|
request_data=data,
|
||||||
|
)
|
||||||
|
return StreamingResponse(
|
||||||
|
generate(response), media_type="audio/mpeg", headers=custom_headers
|
||||||
|
)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
|
@ -1136,6 +1136,8 @@ class CallTypes(Enum):
|
||||||
amoderation = "amoderation"
|
amoderation = "amoderation"
|
||||||
atranscription = "atranscription"
|
atranscription = "atranscription"
|
||||||
transcription = "transcription"
|
transcription = "transcription"
|
||||||
|
aspeech = "aspeech"
|
||||||
|
speech = "speech"
|
||||||
|
|
||||||
|
|
||||||
# Logging function -> log the exact model details + what's being sent | Non-BlockingP
|
# Logging function -> log the exact model details + what's being sent | Non-BlockingP
|
||||||
|
@ -3005,6 +3007,10 @@ def function_setup(
|
||||||
):
|
):
|
||||||
_file_name: BinaryIO = args[1] if len(args) > 1 else kwargs["file"]
|
_file_name: BinaryIO = args[1] if len(args) > 1 else kwargs["file"]
|
||||||
messages = "audio_file"
|
messages = "audio_file"
|
||||||
|
elif (
|
||||||
|
call_type == CallTypes.aspeech.value or call_type == CallTypes.speech.value
|
||||||
|
):
|
||||||
|
messages = kwargs.get("input", "speech")
|
||||||
stream = True if "stream" in kwargs and kwargs["stream"] == True else False
|
stream = True if "stream" in kwargs and kwargs["stream"] == True else False
|
||||||
logging_obj = Logging(
|
logging_obj = Logging(
|
||||||
model=model,
|
model=model,
|
||||||
|
@ -3346,6 +3352,8 @@ def client(original_function):
|
||||||
return result
|
return result
|
||||||
elif "atranscription" in kwargs and kwargs["atranscription"] == True:
|
elif "atranscription" in kwargs and kwargs["atranscription"] == True:
|
||||||
return result
|
return result
|
||||||
|
elif "aspeech" in kwargs and kwargs["aspeech"] == True:
|
||||||
|
return result
|
||||||
|
|
||||||
### POST-CALL RULES ###
|
### POST-CALL RULES ###
|
||||||
post_call_processing(original_response=result, model=model or None)
|
post_call_processing(original_response=result, model=model or None)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue