feat(router): mapped finish reason checkpoint on chat completions

This commit is contained in:
Paolo Antinori 2026-09-18 15:28:13 +02:00
parent f6ec7dfeb9
commit ebe4967783
No known key found for this signature in database

View file

@ -2574,6 +2574,16 @@ class Router:
llm_provider="",
)
## CHECK MAPPED FINISH REASON ERROR ##
if isinstance(response, ModelResponse):
if self._should_raise_mapped_finish_reason_error(model=model, response=response, kwargs=kwargs):
raise self._finish_reason_failure_error(
model=model, reason=self._get_mapped_finish_reason(response)
)
self._account_mapped_finish_reason_failure(
model=model, deployment=deployment, response=response, kwargs=kwargs
)
if (
isinstance(response, CustomStreamWrapper)
and response.completion_stream is None
@ -3698,6 +3708,16 @@ class Router:
llm_provider="",
)
## CHECK MAPPED FINISH REASON ERROR ##
if isinstance(response, ModelResponse):
if self._should_raise_mapped_finish_reason_error(model=model, response=response, kwargs=kwargs):
raise self._finish_reason_failure_error(
model=model, reason=self._get_mapped_finish_reason(response)
)
self._account_mapped_finish_reason_failure(
model=model, deployment=deployment, response=response, kwargs=kwargs
)
if (
isinstance(response, CustomStreamWrapper)
and response.completion_stream is None