refactor: prompt

This commit is contained in:
莘权 马 2023-09-04 10:11:19 +08:00
parent b5c149f225
commit e06aa62ac4

View file

@ -27,6 +27,26 @@ class TalkAction(Action):
@property
def prompt(self):
prompt = ""
if CONFIG.agent_description:
prompt = (
f"You are {CONFIG.agent_description}. Your responses should align with the role-play agreement, "
f"maintaining the character's persona and habits. When faced with unrelated questions, playfully "
f"decline to answer without revealing your AI nature to preserve the character's image.\n\n"
)
prompt += f"Background knowledge:\n{self._knowledge}\n\n" if self._knowledge else ""
prompt += f"{self._history_summary}\n\n"
if self._history_summary != "":
prompt += "According to the historical conversation above, "
language = CONFIG.language or DEFAULT_LANGUAGE
prompt += (
f"Answer the following questions in {language}, and the answers must follow the Markdown format.\n "
f"{self._talk}"
)
return prompt
@property
def prompt_new(self):
kvs = {
"{role}": CONFIG.agent_description or "",
"{history}": self._history_summary or "",