Skip to content

Commit 1d52f1b

Browse files
authored
Fix assertion failure during chat session.
This fixes the following assert that is easy to repro in any chat session: ``` Traceback (most recent call last): File "/home/ubuntu/cali/torchchat/torchchat.py", line 69, in <module> generate_main(args) File "/home/ubuntu/cali/torchchat/generate.py", line 896, in main for _ in gen.chat(generator_args): File "/home/ubuntu/cali/torchchat/generate.py", line 748, in chat self.chat_formatter.encode_header( File "/home/ubuntu/cali/torchchat/generate.py", line 53, in encode_header tokens.extend(self.tokenizer.encode(role, bos=False, eos=False)) File "/home/ubuntu/cali/torchchat/tokenizer/tiktoken.py", line 133, in encode assert type(s) is str ``` I believe this regressed with #1035.
1 parent 7465842 commit 1d52f1b

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

generate.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -745,9 +745,7 @@ def chat(
745745
{"role": "user", "content": prompt}
746746
)
747747
encoded.extend(
748-
self.chat_formatter.encode_header(
749-
{"role": "assistant", "content": ""}
750-
)
748+
self.chat_formatter.encode_header("assistant")
751749
)
752750
encoded = torch.tensor(
753751
encoded, dtype=torch.int, device=self.builder_args.device

0 commit comments

Comments
 (0)