Bugfix: Chat completion requests fail with UnboundLocalError: finish_reason variable not initialized (#307)

* fix issue #306

* removed whitespaces for ruff
This commit is contained in:
Benjamin Oldenburg
2025-03-16 07:31:21 +07:00
committed by GitHub
parent d98c0bd3f6
commit a20abe2d33

View File

@@ -74,7 +74,9 @@ def _create_response(
logprob_response = ChatCompletionLogprobs(content=collected_token_probs)
# Finish reason will always be present in a completion
# Initialize finish_reason with a default value or from generation data
finish_reason = generation.get("finish_reason", "stop")
# If a tool call is present, mark the finish reason as such
if message.tool_calls:
finish_reason = "tool_calls"