mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-06 02:48:13 +00:00
refactor(grayswan): tighten post-call context typing and wire test helpers
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
e77024f79f
commit
cd0e9cee7c
3 changed files with 9 additions and 9 deletions
|
|
@ -617,7 +617,7 @@ class GraySwanGuardrail(CustomGuardrail):
|
|||
"""
|
||||
from litellm.llms import load_guardrail_translation_mappings
|
||||
|
||||
call_type: Final = getattr(logging_obj, "call_type", None) or getattr(
|
||||
call_type: Final = (logging_obj.call_type if logging_obj is not None else None) or getattr(
|
||||
request_data.get("litellm_logging_obj"), "call_type", None
|
||||
)
|
||||
if not isinstance(call_type, str):
|
||||
|
|
|
|||
|
|
@ -119,16 +119,17 @@ def _chat_provider(message: dict[str, JsonValue]):
|
|||
|
||||
|
||||
def _monitor_bodies(vendor: Wire, expected: int = 1) -> tuple[dict[str, JsonValue], ...]:
|
||||
scans: Final = eventually(
|
||||
lambda: tuple(
|
||||
collected: list[dict[str, JsonValue]] = [] # mutable-ok: accumulator across polling attempts
|
||||
|
||||
def drain_new() -> tuple[dict[str, JsonValue], ...]:
|
||||
collected.extend(
|
||||
_JSON_OBJECT.validate_json(request.body)
|
||||
for request in vendor.drain()
|
||||
if request.target == "/cygnal/monitor"
|
||||
),
|
||||
lambda bodies: len(bodies) >= expected,
|
||||
seconds=30,
|
||||
)
|
||||
return scans
|
||||
)
|
||||
return tuple(collected)
|
||||
|
||||
return eventually(drain_new, lambda bodies: len(bodies) >= expected, seconds=30)
|
||||
|
||||
|
||||
def test_post_call_sends_request_conversation_and_tools(gateway: Gateway, tmp_path: Path) -> None:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
import pytest
|
||||
from fastapi import HTTPException
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue