utils#
- besser.agent.nlp.utils.merge_llm_consecutive_messages(messages)[source]#
Merges consecutive user and assistant messages. Necessary for HuggingFace LLMs, where the message pattern must be user/assistant/user/assistant…
A message looks like the following:
{'role': 'user', 'content': 'Hi'} # For user messages {'role': 'assistant', 'content': 'Hi'} # For assistant, i.e. LLM, messages