Skip to content

Refactor all_text to remaining_text #1658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions llama_cpp/llama.py
Original file line number Diff line number Diff line change
Expand Up @@ -1519,15 +1519,15 @@ def logit_bias_processor(

if stream:
remaining_tokens = completion_tokens[returned_tokens:]
all_text = self.detokenize(
remaining_text = self.detokenize(
remaining_tokens,
prev_tokens=prompt_tokens + completion_tokens[:returned_tokens],
)
any_stop = [s for s in stop_sequences if s in all_text]
any_stop = [s for s in stop_sequences if s in remaining_text]
if len(any_stop) > 0:
end = min(all_text.index(stop) for stop in any_stop)
end = min(remaining_text.index(stop) for stop in any_stop)
else:
end = len(all_text)
end = len(remaining_text)

token_end_position = 0
for token in remaining_tokens:
Expand Down