mirror of
https://github.com/acon96/home-llm.git
synced 2026-01-08 21:28:05 -05:00
Merge pull request #306 from syn-nick/develop
Handle empty finish_reason
This commit is contained in:
@@ -217,8 +217,9 @@ class GenericOpenAIAPIClient(LocalLLMClient):
|
||||
response_text = choice["text"]
|
||||
streamed = False
|
||||
|
||||
if not streamed or streamed and choice["finish_reason"]:
|
||||
if choice["finish_reason"] == "length" or choice["finish_reason"] == "content_filter":
|
||||
if not streamed or (streamed and choice.get("finish_reason")):
|
||||
finish_reason = choice.get("finish_reason")
|
||||
if finish_reason in ("length", "content_filter"):
|
||||
_LOGGER.warning("Model response did not end on a stop token (unfinished sentence)")
|
||||
|
||||
return response_text, tool_calls
|
||||
@@ -405,4 +406,4 @@ class GenericOpenAIResponsesAPIClient(LocalLLMClient):
|
||||
_LOGGER.debug(f"Err was: {err}")
|
||||
_LOGGER.debug(f"Request was: {request_params}")
|
||||
_LOGGER.debug(f"Result was: {response}")
|
||||
return TextGenerationResult(raise_error=True, error_msg=f"Failed to communicate with the API! {err}")
|
||||
return TextGenerationResult(raise_error=True, error_msg=f"Failed to communicate with the API! {err}")
|
||||
|
||||
Reference in New Issue
Block a user