mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-15 09:12:18 +00:00
fix(guardrails): label the diff-mode round with the choice it inspected
The ended-stream path labelled every inspection, including a single choice, while a diff-mode round only labelled the per-choice rounds of an n>1 stream. A single-choice round logged no choice at all. Label it with the choice its texts came from.
This commit is contained in:
parent
e53c6fc8bf
commit
e54d4b8d12
2 changed files with 3 additions and 1 deletions
|
|
@ -951,6 +951,8 @@ class OpenAIChatCompletionsHandler(BaseTranslation):
|
|||
prior_responses: Final = resolved_request_data.get("responses", missing)
|
||||
prior_choice_index: Final = resolved_request_data.get("guardrail_choice_index", missing)
|
||||
resolved_request_data.pop("guardrail_choice_index", None)
|
||||
if len(indices) == 1:
|
||||
resolved_request_data["guardrail_choice_index"] = indices[0]
|
||||
if "responses" not in resolved_request_data:
|
||||
resolved_request_data["responses"] = responses_so_far
|
||||
self.merge_user_api_key_metadata_into_request(resolved_request_data, user_api_key_dict)
|
||||
|
|
|
|||
|
|
@ -1702,7 +1702,7 @@ class TestOpenAIChatCompletionsHandlerStreamingOutput:
|
|||
request_data=request_data,
|
||||
stream_transform_sink=StreamTransformSink(),
|
||||
)
|
||||
assert LabelReadingGuardrail.seen == [None]
|
||||
assert LabelReadingGuardrail.seen == [0]
|
||||
assert request_data["guardrail_choice_index"] == 7
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue