mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-05 08:23:17 +00:00
log input of response API
This commit is contained in:
@@ -120,6 +120,18 @@ async def aresponses(
|
||||
response_api_optional_params=response_api_optional_params,
|
||||
)
|
||||
|
||||
# Pre Call logging
|
||||
litellm_logging_obj.update_environment_variables(
|
||||
model=model,
|
||||
user=user,
|
||||
optional_params=dict(responses_api_request_params),
|
||||
litellm_params={
|
||||
"litellm_call_id": litellm_call_id,
|
||||
**responses_api_request_params,
|
||||
},
|
||||
custom_llm_provider=custom_llm_provider,
|
||||
)
|
||||
|
||||
response = await base_llm_http_handler.async_response_api_handler(
|
||||
model=model,
|
||||
input=input,
|
||||
|
||||
@@ -716,6 +716,11 @@ def function_setup( # noqa: PLR0915
|
||||
call_type == CallTypes.aspeech.value or call_type == CallTypes.speech.value
|
||||
):
|
||||
messages = kwargs.get("input", "speech")
|
||||
elif (
|
||||
call_type == CallTypes.aresponses.value
|
||||
or call_type == CallTypes.responses.value
|
||||
):
|
||||
messages = args[0] if len(args) > 0 else kwargs["input"]
|
||||
else:
|
||||
messages = "default-message-value"
|
||||
stream = True if "stream" in kwargs and kwargs["stream"] is True else False
|
||||
|
||||
@@ -76,8 +76,9 @@ async def test_basic_openai_responses_api_non_streaming_with_logging():
|
||||
litellm.set_verbose = True
|
||||
test_custom_logger = TestCustomLogger()
|
||||
litellm.callbacks = [test_custom_logger]
|
||||
request_model = "gpt-4o"
|
||||
response = await litellm.aresponses(
|
||||
model="gpt-4o",
|
||||
model=request_model,
|
||||
input="hi",
|
||||
)
|
||||
|
||||
@@ -111,9 +112,14 @@ async def test_basic_openai_responses_api_non_streaming_with_logging():
|
||||
assert test_custom_logger.standard_logging_object["response_cost"] > 0
|
||||
|
||||
# validate response id matches OpenAI
|
||||
assert test_custom_logger.standard_logging_object["id"] == response["id"]
|
||||
|
||||
# validate model matches
|
||||
assert test_custom_logger.standard_logging_object["model"] == request_model
|
||||
|
||||
# validate messages matches
|
||||
assert test_custom_logger.standard_logging_object["messages"] == [
|
||||
{"content": "hi", "role": "user"}
|
||||
]
|
||||
|
||||
# validate responses matches
|
||||
|
||||
Reference in New Issue
Block a user