Update litellm/proxy/response_api_endpoints/endpoints.py

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
This commit is contained in:
Cesar Garcia 2026-03-04 18:51:01 -03:00 committed by Chesars
parent 018750e0cd
commit 39762983b1

View file

@ -469,6 +469,7 @@ async def count_response_input_tokens(
if isinstance(input_data, str):
messages.append({"role": "user", "content": input_data})
elif isinstance(input_data, list):
elif isinstance(input_data, list):
for item in input_data:
if isinstance(item, dict):
@ -480,6 +481,18 @@ async def count_response_input_tokens(
"content": item.get("output", ""),
"tool_call_id": item.get("call_id", ""),
})
elif item.get("type") == "function_call":
messages.append({
"role": "assistant",
"tool_calls": [{
"id": item.get("call_id", ""),
"type": "function",
"function": {
"name": item.get("name", ""),
"arguments": item.get("arguments", ""),
},
}],
})
else:
messages.append({"role": role, "content": content})
elif isinstance(item, str):