[ChatStream] ChatPrompt for Rakuten/RakutenAI-7B-chat

[ChatStream] ChatPrompt for Rakuten/RakutenAI-7B-chat

Here is the ChatPrompt for Rakuten/RakutenAI-7B-chat, which was released yesterday.

from chatstream import AbstractChatPrompt

SYSTEM_PROMPT = """\
A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions. \
"""


class ChatPromptRakutenMistral(AbstractChatPrompt):

    def __init__(self):
        super().__init__()  # Call the initialization of the base class
        self.set_system(f"{SYSTEM_PROMPT}")
        self.set_requester("USER")
        self.set_responder("ASSISTANT")

    def get_stop_strs(self):
        if not self.chat_mode:
            return None
        return []

    def get_replacement_when_input(self):
        return None

    def get_replacement_when_output(self):  # replace when response_text gotten
        return None

    def create_prompt(self, opts={}):
        if self.chat_mode == False:
            return self.get_requester_last_msg()

        # Build the prompt for the case where Chat Mode == True
        ret = self.system

        for chat_content in self.get_contents(opts):

            chat_content_role = chat_content.get_role()
            chat_content_role_type = chat_content.get_role_type()
            chat_content_message = chat_content.get_message()

            if chat_content_role:

                if chat_content_message:

                    merged_message = chat_content_role + ": " + chat_content_message + " "
                else:
                    merged_message = chat_content_role + ":"

                ret += merged_message

        return ret

    async def build_initial_prompt(self, chat_prompt):
        # No initial prompt is implemented
        pass


Read more