mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-24 00:52:24 +00:00
fix(proxy): look the entity spend table up lazily so only the selected batcher table is touched
This commit is contained in:
parent
1b568319d0
commit
51eaad657b
1 changed files with 11 additions and 9 deletions
|
|
@ -141,16 +141,18 @@ _EntitySpendTable: TypeAlias = Literal[
|
|||
]
|
||||
|
||||
|
||||
_ENTITY_SPEND_TABLES: Final[Mapping[_EntitySpendTable, Callable[[_SpendBatch], BatchTable]]] = MappingProxyType(
|
||||
{
|
||||
"litellm_tagtable": lambda batcher: batcher.litellm_tagtable,
|
||||
"litellm_agentstable": lambda batcher: batcher.litellm_agentstable,
|
||||
"litellm_modelaccessgroupbudgettable": lambda batcher: batcher.litellm_modelaccessgroupbudgettable,
|
||||
"litellm_projecttable": lambda batcher: batcher.litellm_projecttable,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def _entity_spend_table(batcher: _SpendBatch, table_accessor: _EntitySpendTable) -> BatchTable:
|
||||
tables: Final[Mapping[_EntitySpendTable, BatchTable]] = MappingProxyType(
|
||||
{
|
||||
"litellm_tagtable": batcher.litellm_tagtable,
|
||||
"litellm_agentstable": batcher.litellm_agentstable,
|
||||
"litellm_modelaccessgroupbudgettable": batcher.litellm_modelaccessgroupbudgettable,
|
||||
"litellm_projecttable": batcher.litellm_projecttable,
|
||||
}
|
||||
)
|
||||
return tables[table_accessor]
|
||||
return _ENTITY_SPEND_TABLES[table_accessor](batcher)
|
||||
|
||||
|
||||
class _SpendBatchManager(Protocol):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue