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):
|
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.user = user
|
||||||
self.message = message
|
self.message = message
|
||||||
self.channel = channel
|
self.channel = channel
|
||||||
self.direct = direct
|
self.direct = direct
|
||||||
|
self.historise_question = historise_question
|
||||||
|
|
||||||
|
|
||||||
class AIResponse(AIMessageBase):
|
class AIResponse(AIMessageBase):
|
||||||
@ -322,7 +323,12 @@ class AIResponder(object):
|
|||||||
else:
|
else:
|
||||||
self.shrink_history_by_one(index + 1)
|
self.shrink_history_by_one(index + 1)
|
||||||
|
|
||||||
def update_history(self, question: Dict[str, Any], answer: Dict[str, Any], limit: int) -> None:
|
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(question)
|
||||||
self.history.append(answer)
|
self.history.append(answer)
|
||||||
while len(self.history) > limit:
|
while len(self.history) > limit:
|
||||||
@ -382,7 +388,7 @@ class AIResponder(object):
|
|||||||
answer['content'] = str(answer_message)
|
answer['content'] = str(answer_message)
|
||||||
|
|
||||||
# Update message history
|
# 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)}")
|
logging.info(f"got this answer:\n{str(answer_message)}")
|
||||||
|
|
||||||
# Return the updated answer message
|
# Return the updated answer message
|
||||||
|
|||||||
@ -73,7 +73,7 @@ class FjerkroaBot(commands.Bot):
|
|||||||
if random.random() < probability:
|
if random.random() < probability:
|
||||||
logging.info(f'Borred with {probability} probability after {elapsed_time}')
|
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.')
|
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:
|
try:
|
||||||
await self.respond(message, self.chat_channel)
|
await self.respond(message, self.chat_channel)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user