NLD-Uni / conversation.py
gheinrich's picture
Release NLD-Uni
300c478
Raw History Blame Contribute Delete
820 Bytes
import copy
class Conversation:
roles = ('<|im_start|>user', '<|im_start|>assistant')
system = '<|im_start|>system\nYou are a helpful language and vision assistant. You are able to understand the visual content that the user provides, and assist the user with a variety of tasks using natural language.'
def __init__(self):
self.messages = []
def copy(self):
return copy.deepcopy(self)
def append_message(self, role, message):
self.messages.append((role, message))
def get_prompt(self):
text = self.system + '<|im_end|>\n' if self.system else ''
for role, message in self.messages:
text += role + '\n'
if message:
text += message + '<|im_end|>\n'
return text
conv_templates = {'ministral': Conversation()}