Update app.py

This commit is contained in:
Saifeddine ALOUI 2024-05-29 12:23:54 +02:00 committed by GitHub
parent 144e0557e5
commit 8197ca7b9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1071,14 +1071,14 @@ class LollmsApplication(LoLLMsCom):
# Tokenize the message content
if self.config.use_model_name_in_discussions:
if message.model:
msg = "\n" + self.config.discussion_prompt_separator + message.sender + f"({message.model}): " + message.content.strip()
msg = f"{separator_template}{start_header_id_template}{message.sender}({message.model}){end_header_id_template}" + message.content.strip()
else:
msg = "\n" + self.config.discussion_prompt_separator + message.sender + ": " + message.content.strip()
msg = f"{separator_template}{start_header_id_template}{message.sender}{end_header_id_template}" + message.content.strip()
message_tokenized = self.model.tokenize(msg)
else:
message_tokenized = self.model.tokenize(
"\n" + self.config.discussion_prompt_separator + message.sender + ": " + message.content.strip())
f"{separator_template}{start_header_id_template}{message.sender}{end_header_id_template}" + message.content.strip()
)
# Check if adding the message will exceed the available space
if tokens_accumulated + len(message_tokenized) > available_space-n_tokens:
# Update the cumulative number of tokens