Do not historise the boreness question.
This commit is contained in:
parent
67f8339cd6
commit
8c718ad272
@ -87,11 +87,12 @@ class AIMessageBase(object):
|
||||
|
||||
|
||||
class AIMessage(AIMessageBase):
|
||||
def __init__(self, user: str, message: str, channel: str = "chat", direct: bool = False) -> None:
|
||||
def __init__(self, user: str, message: str, channel: str = "chat", direct: bool = False, historise_question: bool = True) -> None:
|
||||
self.user = user
|
||||
self.message = message
|
||||
self.channel = channel
|
||||
self.direct = direct
|
||||
self.historise_question = historise_question
|
||||
|
||||
|
||||
class AIResponse(AIMessageBase):
|
||||
@ -322,8 +323,13 @@ class AIResponder(object):
|
||||
else:
|
||||
self.shrink_history_by_one(index + 1)
|
||||
|
||||
def update_history(self, question: Dict[str, Any], answer: Dict[str, Any], limit: int) -> None:
|
||||
self.history.append(question)
|
||||
def update_history(self,
|
||||
question: Dict[str, Any],
|
||||
answer: Dict[str, Any],
|
||||
limit: int,
|
||||
historise_question: bool = True) -> None:
|
||||
if historise_question:
|
||||
self.history.append(question)
|
||||
self.history.append(answer)
|
||||
while len(self.history) > limit:
|
||||
self.shrink_history_by_one()
|
||||
@ -382,7 +388,7 @@ class AIResponder(object):
|
||||
answer['content'] = str(answer_message)
|
||||
|
||||
# Update message history
|
||||
self.update_history(messages[-1], answer, limit)
|
||||
self.update_history(messages[-1], answer, limit, message.historise_question)
|
||||
logging.info(f"got this answer:\n{str(answer_message)}")
|
||||
|
||||
# Return the updated answer message
|
||||
|
||||
@ -73,7 +73,7 @@ class FjerkroaBot(commands.Bot):
|
||||
if random.random() < probability:
|
||||
logging.info(f'Borred with {probability} probability after {elapsed_time}')
|
||||
boreness_prompt = self.config.get('boreness-prompt', 'Pretend that you just now thought of something, be creative.')
|
||||
message = AIMessage('system', boreness_prompt, self.config.get('chat-channel', 'chat'), True)
|
||||
message = AIMessage('system', boreness_prompt, self.config.get('chat-channel', 'chat'), True, False)
|
||||
try:
|
||||
await self.respond(message, self.chat_channel)
|
||||
except Exception as err:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user