mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-18 09:45:23 +00:00
fix(logging): preserve scalar tags for background settlement
This commit is contained in:
parent
104695e467
commit
a92c39bef6
2 changed files with 9 additions and 3 deletions
|
|
@ -307,8 +307,13 @@ def _spend_metadata(logging_obj: "LiteLLMLoggingObj") -> Mapping[str, object]:
|
|||
rebuilt logging object has no request headers to derive them from.
|
||||
"""
|
||||
litellm_params: Final = _OBJECT_DICT.validate_python(logging_obj.model_call_details.get("litellm_params") or {})
|
||||
metadata: Final = _OBJECT_MAPPING.validate_python(
|
||||
get_litellm_metadata_from_kwargs(kwargs=logging_obj.model_call_details)
|
||||
)
|
||||
if metadata.get("tags") and not isinstance(metadata.get("tags"), list):
|
||||
return metadata
|
||||
return {
|
||||
**_OBJECT_MAPPING.validate_python(get_litellm_metadata_from_kwargs(kwargs=logging_obj.model_call_details)),
|
||||
**metadata,
|
||||
**_request_tags(litellm_params),
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -484,13 +484,14 @@ async def test_schedule_registers_an_agent_only_create_that_names_no_model():
|
|||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_schedule_registers_a_create_whose_tags_are_a_string_and_keeps_them_as_sent():
|
||||
@pytest.mark.parametrize("metadata_field", ["metadata", "litellm_metadata"])
|
||||
async def test_schedule_registers_a_create_whose_tags_are_a_string_and_keeps_them_as_sent(metadata_field):
|
||||
"""
|
||||
The regression: storing the create's context read string tags as a list
|
||||
and raised, so a create sent with a tags string answered with an error
|
||||
after the provider had already started the interaction.
|
||||
"""
|
||||
logging_obj = _logging_obj(litellm_params={"metadata": _create_metadata(tags="team-a,nightly-batch")})
|
||||
logging_obj = _logging_obj(litellm_params={metadata_field: _create_metadata(tags="team-a,nightly-batch")})
|
||||
store = InMemoryBackgroundSettlementStore()
|
||||
|
||||
task = await maybe_schedule_background_interaction_cost_polling(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue