[FEAT] JSON constrained support (#1125)
Co-authored-by: Yineng Zhang <me@zhyncs.com>
This commit is contained in:
@@ -268,7 +268,14 @@ class Req:
|
||||
|
||||
all_text = self.origin_input_text + self.decoded_text + jump_forward_str
|
||||
all_ids = self.tokenizer.encode(all_text)
|
||||
if not all_ids:
|
||||
warnings.warn("Encoded all_text resulted in empty all_ids")
|
||||
return False
|
||||
|
||||
prompt_tokens = len(self.origin_input_ids_unpadded)
|
||||
if prompt_tokens > len(all_ids):
|
||||
warnings.warn("prompt_tokens is larger than encoded all_ids")
|
||||
return False
|
||||
|
||||
if all_ids[prompt_tokens - 1] != self.origin_input_ids_unpadded[-1]:
|
||||
# TODO(lsyin): fix token fusion
|
||||
|
||||
Reference in New Issue
Block a user