mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-01 02:02:20 +00:00
fix(opentelemetry): use separate hashable_guardrail_mode to satisfy mypy
The previous reassignment of guardrail_mode to a tuple tripped mypy because the variable inferred type from .get() is GuardrailEventHooks | list[GuardrailEventHooks] | GuardrailMode | None, which does not include tuple. Use a separately-named Any-typed binding for the hashable form passed to _emit_once, preserving the original runtime fix and keeping mypy green.
This commit is contained in:
parent
f6d117c498
commit
cecc20eeba
1 changed files with 6 additions and 3 deletions
|
|
@ -1570,14 +1570,17 @@ class OpenTelemetry(OTELGenAISemconvMixin, CustomLogger):
|
|||
# (e.g. ``mode: ["pre_call", "post_call"]``); ``_emit_once``
|
||||
# requires hashable scope parts, so normalize lists to tuples.
|
||||
guardrail_mode = guardrail_information.get("guardrail_mode")
|
||||
if isinstance(guardrail_mode, list):
|
||||
guardrail_mode = tuple(guardrail_mode)
|
||||
hashable_guardrail_mode: Any = (
|
||||
tuple(guardrail_mode)
|
||||
if isinstance(guardrail_mode, list)
|
||||
else guardrail_mode
|
||||
)
|
||||
if not self._emit_once(
|
||||
kwargs,
|
||||
"guardrail",
|
||||
guardrail_information.get("guardrail_name"),
|
||||
start_time_float,
|
||||
guardrail_mode,
|
||||
hashable_guardrail_mode,
|
||||
):
|
||||
continue
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue