mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-22 10:40:46 +00:00
fix(proxy): satisfy LIT010 and LIT014 in the tool discovery buffer
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
e78eab9d69
commit
d642ada2f7
3 changed files with 5 additions and 4 deletions
|
|
@ -9,6 +9,7 @@ import json
|
|||
from collections.abc import Mapping, Sequence
|
||||
from datetime import datetime
|
||||
from functools import reduce
|
||||
from itertools import chain
|
||||
from typing import TYPE_CHECKING, Any, Final, Literal, TypeAlias, TypeVar, cast
|
||||
|
||||
from pydantic import TypeAdapter
|
||||
|
|
@ -604,7 +605,7 @@ class RedisUpdateBuffer:
|
|||
if not entries:
|
||||
return ()
|
||||
batches: Final = tuple(_TOOL_DISCOVERY_ITEMS.validate_json(entry) for entry in entries)
|
||||
return aggregate_tool_discoveries(item for batch in batches for item in batch)
|
||||
return aggregate_tool_discoveries(chain.from_iterable(batches))
|
||||
|
||||
@with_service_target(SPEND_QUEUE_TARGET)
|
||||
async def store_spend_logs_in_redis(
|
||||
|
|
|
|||
|
|
@ -26,8 +26,7 @@ def aggregate_tool_discoveries(items: Iterable[ToolDiscoveryQueueItem]) -> tuple
|
|||
"""Collapse items to one per tool_name, summing call_count, in first-seen order."""
|
||||
by_name: dict[str, ToolDiscoveryQueueItem] = {} # mutable-ok: single pass fold keyed by tool_name
|
||||
for item in items:
|
||||
tool_name = item.get("tool_name", "")
|
||||
if not tool_name:
|
||||
if not (tool_name := item.get("tool_name", "")):
|
||||
continue
|
||||
by_name[tool_name] = _merged(by_name.get(tool_name), item)
|
||||
return tuple(by_name.values())
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ Admins use the management endpoints to read and update input_policy / output_pol
|
|||
import uuid
|
||||
from collections.abc import Mapping, Sequence
|
||||
from datetime import datetime, timezone
|
||||
from itertools import chain
|
||||
from types import MappingProxyType
|
||||
from typing import TYPE_CHECKING, Final, Protocol
|
||||
|
||||
|
|
@ -159,7 +160,7 @@ def build_tool_bulk_upsert(items: Sequence[ToolDiscoveryQueueItem]) -> tuple[str
|
|||
' "last_used_at" = EXCLUDED."last_used_at",\n'
|
||||
' "updated_at" = EXCLUDED."updated_at"'
|
||||
)
|
||||
return sql, tuple(value for item in items for value in _tool_row_params(item))
|
||||
return sql, tuple(chain.from_iterable(map(_tool_row_params, items)))
|
||||
|
||||
|
||||
async def batch_upsert_tools(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue