Skip to content

Commit

Permalink
[python] fix last token fetch logic (#2423)
Browse files Browse the repository at this point in the history
  • Loading branch information
sindhuvahinis authored Oct 9, 2024
1 parent bd0db03 commit 79d0c3e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 1 addition & 3 deletions engines/python/setup/djl_python/output_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
from djl_python.request_io import TextGenerationOutput
from djl_python.utils import wait_till_generation_finished

ERR_MSG = "Inference error occurred. Check CloudWatch metrics or model server logs for more details."


def output_formatter(function):
"""
Expand Down Expand Up @@ -122,7 +120,7 @@ def _json_output_formatter(request_output: TextGenerationOutput):
# partial generation response that may exist
result = {
"generated_text": None,
"error": final_token.error_msg if final_token else ERR_MSG,
"error": final_token.error_msg,
"code": 400,
"details": details,
}
Expand Down
2 changes: 1 addition & 1 deletion engines/python/setup/djl_python/request_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def get_next_token(self) -> (Token, bool, bool):
return None, False, False

def get_last_token(self) -> Optional[Token]:
if self._last_token_index:
if self._last_token_index is not None:
return self.tokens[self._last_token_index]
return None

Expand Down

0 comments on commit 79d0c3e

Please sign in to comment.