From 5922437b7f7c11964db1b4f5fa5f46134f73dded Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Boisvert?= Date: Fri, 29 Nov 2024 17:05:32 -0500 Subject: [PATCH] Update huggingface_utils.py --- src/agentlab/llm/huggingface_utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/agentlab/llm/huggingface_utils.py b/src/agentlab/llm/huggingface_utils.py index 06b7adbe..153978b1 100644 --- a/src/agentlab/llm/huggingface_utils.py +++ b/src/agentlab/llm/huggingface_utils.py @@ -6,6 +6,7 @@ from transformers import AutoTokenizer, GPT2TokenizerFast from agentlab.llm.base_api import AbstractChatModel +from agentlab.llm.llm_utils import Discussion from agentlab.llm.prompt_templates import PromptTemplate, get_prompt_template @@ -59,7 +60,8 @@ def __call__( if self.tokenizer: # messages_formated = _convert_messages_to_dict(messages) ## ? try: - messages.merge() + if isinstance(messages, Discussion): + messages.merge() prompt = self.tokenizer.apply_chat_template(messages, tokenize=False) except Exception as e: if "Conversation roles must alternate" in str(e):