mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-07 07:12:28 +00:00
fix: use chat format in tools test, include tools/system in local fallback
This commit is contained in:
+5
-1
@@ -7617,9 +7617,13 @@ async def acount_tokens(
|
||||
)
|
||||
|
||||
# Fallback to local tiktoken-based token counting
|
||||
fallback_messages = messages or []
|
||||
if system and fallback_messages:
|
||||
fallback_messages = [{"role": "system", "content": system}] + fallback_messages
|
||||
local_count = litellm.token_counter(
|
||||
model=model,
|
||||
messages=messages or [],
|
||||
messages=fallback_messages,
|
||||
tools=tools,
|
||||
)
|
||||
|
||||
return TokenCountResponse(
|
||||
|
||||
@@ -71,9 +71,11 @@ def test_acount_tokens_with_tools():
|
||||
tools = [
|
||||
{
|
||||
"type": "function",
|
||||
"name": "get_weather",
|
||||
"description": "Get weather info",
|
||||
"parameters": {"type": "object", "properties": {"city": {"type": "string"}}},
|
||||
"function": {
|
||||
"name": "get_weather",
|
||||
"description": "Get weather info",
|
||||
"parameters": {"type": "object", "properties": {"city": {"type": "string"}}},
|
||||
},
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user