Fix reaction handling.

This commit is contained in:
OK
2024-03-17 13:25:02 +01:00
parent 73d9b9184d
commit 1bff1c9719
4 changed files with 20 additions and 17 deletions
+3 -2
View File
@@ -111,15 +111,16 @@ class OpenAIResponder(AIResponder, LeonardoAIDrawMixIn):
logging.warning(f"failed to translate the text: {repr(err)}")
return text
async def memory_rewrite(self, memory: str, user: str, question: str, answer: str) -> str:
async def memory_rewrite(self, memory: str, message_user: str, answer_user: str, question: str, answer: str) -> str:
if 'memory-model' not in self.config:
return memory
messages = [{'role': 'system', 'content': self.config.get('memory-system', 'You are an memory assistant.')},
{'role': 'user', 'content': f'Here is my previous memory:\n```\n{memory}\n```\n\n'
f'Here is my conversanion:\n```\n{user}: {question}\n\nassistant: {answer}\n```\n\n'
f'Here is my conversanion:\n```\n{message_user}: {question}\n\n{answer_user}: {answer}\n```\n\n'
f'Please rewrite the memory in a way, that it contain the content mentioned in conversation. '
f'The whole memory should not be too long, summarize if required. '
f'Write just new memory data without any comments.'}]
logging.info(f'Rewrite memory:\n{pp(messages)}')
try:
# logging.info(f'send this memory request:\n{pp(messages)}')
result = await openai_chat(self.client,