Merge pull request #4451 from BerriAI/litellm_azure_fix_pre_post_logging

[Fix] Azure Post-API Call occurs before Pre-API Call in CustomLogger
This commit is contained in:
Ishaan Jaff 2024-06-27 20:18:14 -07:00 committed by GitHub
commit 7bedb5ca52
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 2 deletions

View file

@ -660,8 +660,16 @@ class AzureChatCompletion(BaseLLM):
response = await azure_client.chat.completions.create( response = await azure_client.chat.completions.create(
**data, timeout=timeout **data, timeout=timeout
) )
stringified_response = response.model_dump()
logging_obj.post_call(
input=data["messages"],
api_key=api_key,
original_response=stringified_response,
additional_args={"complete_input_dict": data},
)
return convert_to_model_response_object( return convert_to_model_response_object(
response_object=response.model_dump(), response_object=stringified_response,
model_response_object=model_response, model_response_object=model_response,
) )
except AzureOpenAIError as e: except AzureOpenAIError as e:

View file

@ -1025,7 +1025,7 @@ def completion(
client=client, # pass AsyncAzureOpenAI, AzureOpenAI client client=client, # pass AsyncAzureOpenAI, AzureOpenAI client
) )
if optional_params.get("stream", False) or acompletion == True: if optional_params.get("stream", False):
## LOGGING ## LOGGING
logging.post_call( logging.post_call(
input=messages, input=messages,