fix(utils.py): add more logging

This commit is contained in:
Krrish Dholakia 2023-12-12 12:27:59 -08:00
parent bdf29ca71f
commit d6669fe9e3
4 changed files with 4 additions and 0 deletions

Binary file not shown.

BIN
dist/litellm-1.12.6.dev1.tar.gz vendored Normal file

Binary file not shown.

View file

@ -190,6 +190,7 @@ async def acompletion(*args, **kwargs):
# Call the synchronous function using run_in_executor # Call the synchronous function using run_in_executor
response = await loop.run_in_executor(None, func_with_context) response = await loop.run_in_executor(None, func_with_context)
if kwargs.get("stream", False): # return an async generator if kwargs.get("stream", False): # return an async generator
print_verbose(f"ENTERS STREAMING FOR ACOMPLETION")
return _async_streaming(response=response, model=model, custom_llm_provider=custom_llm_provider, args=args) return _async_streaming(response=response, model=model, custom_llm_provider=custom_llm_provider, args=args)
else: else:
return response return response
@ -202,6 +203,7 @@ async def acompletion(*args, **kwargs):
async def _async_streaming(response, model, custom_llm_provider, args): async def _async_streaming(response, model, custom_llm_provider, args):
try: try:
async for line in response: async for line in response:
print_verbose(f"line in async streaming: {line}")
yield line yield line
except Exception as e: except Exception as e:
raise exception_type( raise exception_type(
@ -1217,6 +1219,7 @@ def completion(
# "SageMaker is currently not supporting streaming responses." # "SageMaker is currently not supporting streaming responses."
# fake streaming for sagemaker # fake streaming for sagemaker
print_verbose(f"ENTERS SAGEMAKER CUSTOMSTREAMWRAPPER")
resp_string = model_response["choices"][0]["message"]["content"] resp_string = model_response["choices"][0]["message"]["content"]
response = CustomStreamWrapper( response = CustomStreamWrapper(
resp_string, model, custom_llm_provider="sagemaker", logging_obj=logging resp_string, model, custom_llm_provider="sagemaker", logging_obj=logging

View file

@ -5685,6 +5685,7 @@ class CustomStreamWrapper:
else: else:
chunk = next(self.completion_stream) chunk = next(self.completion_stream)
if chunk is not None and chunk != b'': if chunk is not None and chunk != b'':
print_verbose(f"PROCESSED CHUNK PRE CHUNK CREATOR: {chunk}")
response = self.chunk_creator(chunk=chunk) response = self.chunk_creator(chunk=chunk)
if response is None: if response is None:
continue continue